Refactor onDestroy to use onMount return function (#914)

* refactor(select-item): replace onDestroy with onMount return function

* refactor(date-picker): replace onDestroy with onMount return function

* refactor(switch): replace onDestroy with onMount return function

* refactor(composed-modal): replace onDestroy with onMount return function
This commit is contained in:
Eric Liu 2021-11-17 13:20:26 -08:00 committed by GitHub
commit dfd53ce09b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 21 deletions

View file

@ -17,7 +17,7 @@
/** Obtain a reference to the button HTML element */
export let ref = null;
import { afterUpdate, getContext, onDestroy } from "svelte";
import { afterUpdate, getContext, onMount } from "svelte";
const ctx = getContext("ContentSwitcher");
@ -33,8 +33,8 @@
}
});
onDestroy(() => {
unsubscribe();
onMount(() => {
return () => unsubscribe();
});
</script>