Skip to content

Commit 7956867

Browse files
authored
Fix possible exception with ReactDOM.unmountComponentAtNode (#24)
1 parent 8840fde commit 7956867

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/WebComponent.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ export class CustomElement extends HTMLElement {
110110
}
111111

112112
disconnectedCallback() {
113-
ReactDOM.unmountComponentAtNode(_rootShadows.get(this));
113+
const rootEl = _rootShadows.get(this);
114+
if(rootEl) {
115+
ReactDOM.unmountComponentAtNode(_rootShadows.get(this));
116+
}
117+
114118
if (this.rootDiv) {
115119
this.removeChild(this.rootDiv);
116120
delete this.rootDiv;

0 commit comments

Comments
 (0)