The `onDestroy` hook is also run during SSR, so returning destruction function from `onMount` should do the trick.
This commit is contained in:
ptrxyz 2023-01-25 04:15:58 +01:00 committed by GitHub
commit b9359ec7af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -159,11 +159,11 @@
if (parent) {
parent.addEventListener("click", pageClickHandler);
}
});
onDestroy(() => {
if (parent) {
parent.removeEventListener("click", pageClickHandler);
return () => {
if (parent) {
parent.removeEventListener("click", pageClickHandler);
}
}
});
</script>