Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
destroy() {
// TODO: is this right?
this.emitter.emit('did-destroy');
this.emitter.dispose();
ReactDom.unmountComponentAtNode(this.getElement());
}
}
export default async function renderMain({
storyFn,
selectedKind,
selectedStory,
showMain,
forceRender,
}: RenderMainArgs) {
const element = storyFn();
// We need to unmount the existing set of components in the DOM node.
// Otherwise, React may not recreate instances for every story run.
// This could leads to issues like below:
// https://github.com/storybookjs/react-storybook/issues/81
// But forceRender means that it's the same story, so we want too keep the state in that case.
if (!forceRender) {
ReactDOM.unmountComponentAtNode(rootEl);
}
await render(element, rootEl, { name: selectedStory, kind: selectedKind });
showMain();
}
const reload = () => {
ReactDOM.unmountComponentAtNode(config.node);
setTimeout(() => {
// for some reason React 16 does unmountComponentAtNode asynchronously (?)
config.node.innerHTML = '';
render();
}, 0);
};
afterEach(function() {
ReactDOM.unmountComponentAtNode(div);
document.body.removeChild(div);
});
afterEach(() => unmountComponentAtNode(node))
module.hot.accept(['containers/App'], () => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
render();
});
}
executeCode (code, variant) {
const mountNode = this.refs.mount
ReactDOM.unmountComponentAtNode(mountNode)
this.setState({
error: null,
variant
})
if (!code) {
return
}
try {
const compiledCode = this.compileCode(code)
const component = this.evalCode(compiledCode)
ReactDOM.render(component, mountNode)
} catch (err) {
removeContainer = () => {
if (this.container) {
ReactDOM.unmountComponentAtNode(this.container);
this.container.parentNode.removeChild(this.container);
this.container = null;
}
}
const destroyFieldEditor = () => {
const node = document.getElementById(REACT_FIELD_EDITOR_ID);
node && unmountComponentAtNode(node);
};
function deprecatedClose () {
mountNode && unmountComponentAtNode(mountNode)
mountNode = undefined
}
return { close: deprecatedClose }