Skip to content

Commit

Permalink
fix: Unmount component when custom element is disconnected (#53)
Browse files Browse the repository at this point in the history
fix: Unmount search when disconnecting parent web component.
  • Loading branch information
mrderyk authored Mar 8, 2024
1 parent f05f5b6 commit 1cdcb20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ class ReactSearchWebComponent extends HTMLElement {
attributeChangedCallback() {
this.connectedCallback();
}

disconnectedCallback() {
ReactDOM.unmountComponentAtNode(this.mountPoint);
}
}

window.customElements.get("react-search") || window.customElements.define("react-search", ReactSearchWebComponent);
Expand Down

0 comments on commit 1cdcb20

Please sign in to comment.