diff --git a/lib/WebComponent.js b/lib/WebComponent.js index 49dcead..fecae0c 100644 --- a/lib/WebComponent.js +++ b/lib/WebComponent.js @@ -110,7 +110,11 @@ export class CustomElement extends HTMLElement { } disconnectedCallback() { - ReactDOM.unmountComponentAtNode(_rootShadows.get(this)); + const rootEl = _rootShadows.get(this); + if(rootEl) { + ReactDOM.unmountComponentAtNode(_rootShadows.get(this)); + } + if (this.rootDiv) { this.removeChild(this.rootDiv); delete this.rootDiv;