mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
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:
parent
a160ef3b40
commit
dfd53ce09b
4 changed files with 23 additions and 21 deletions
|
@ -70,7 +70,7 @@
|
|||
createEventDispatcher,
|
||||
setContext,
|
||||
afterUpdate,
|
||||
onDestroy,
|
||||
onMount,
|
||||
} from "svelte";
|
||||
import { writable, derived } from "svelte/store";
|
||||
import { createCalendar } from "./createCalendar";
|
||||
|
@ -175,6 +175,15 @@
|
|||
});
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
return () => {
|
||||
if (calendar) {
|
||||
calendar.destroy();
|
||||
calendar = null;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
afterUpdate(() => {
|
||||
if (calendar) {
|
||||
if ($range) {
|
||||
|
@ -188,13 +197,6 @@
|
|||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (calendar) {
|
||||
calendar.destroy();
|
||||
calendar = null;
|
||||
}
|
||||
});
|
||||
|
||||
$: inputValue.set(value);
|
||||
$: value = $inputValue;
|
||||
$: inputValueFrom.set(valueFrom);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue