mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(dropdown): fix ssr issue (#1639)
The `onDestroy` hook is also run during SSR, so returning destruction function from `onMount` should do the trick. For #1638
This commit is contained in:
parent
afa692c9e0
commit
8cb5d538f7
1 changed files with 5 additions and 5 deletions
|
@ -98,7 +98,7 @@
|
||||||
/** Obtain a reference to the button HTML element */
|
/** Obtain a reference to the button HTML element */
|
||||||
export let ref = null;
|
export let ref = null;
|
||||||
|
|
||||||
import { createEventDispatcher, onDestroy, onMount } from "svelte";
|
import { createEventDispatcher, onMount } from "svelte";
|
||||||
import WarningFilled from "../icons/WarningFilled.svelte";
|
import WarningFilled from "../icons/WarningFilled.svelte";
|
||||||
import WarningAltFilled from "../icons/WarningAltFilled.svelte";
|
import WarningAltFilled from "../icons/WarningAltFilled.svelte";
|
||||||
import {
|
import {
|
||||||
|
@ -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>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue