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,12 +159,12 @@
if (parent) { if (parent) {
parent.addEventListener("click", pageClickHandler); parent.addEventListener("click", pageClickHandler);
} }
});
onDestroy(() => { return () => {
if (parent) { if (parent) {
parent.removeEventListener("click", pageClickHandler); parent.removeEventListener("click", pageClickHandler);
} }
}
}); });
</script> </script>