mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
refactor(date-picker): replace onDestroy with onMount return function
This commit is contained in:
parent
1309eaef20
commit
7e919d121f
1 changed files with 10 additions and 8 deletions
|
@ -70,7 +70,7 @@
|
||||||
createEventDispatcher,
|
createEventDispatcher,
|
||||||
setContext,
|
setContext,
|
||||||
afterUpdate,
|
afterUpdate,
|
||||||
onDestroy,
|
onMount,
|
||||||
} from "svelte";
|
} from "svelte";
|
||||||
import { writable, derived } from "svelte/store";
|
import { writable, derived } from "svelte/store";
|
||||||
import { createCalendar } from "./createCalendar";
|
import { createCalendar } from "./createCalendar";
|
||||||
|
@ -175,6 +175,15 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
return () => {
|
||||||
|
if (calendar) {
|
||||||
|
calendar.destroy();
|
||||||
|
calendar = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {
|
||||||
if (calendar) {
|
if (calendar) {
|
||||||
if ($range) {
|
if ($range) {
|
||||||
|
@ -188,13 +197,6 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
|
||||||
if (calendar) {
|
|
||||||
calendar.destroy();
|
|
||||||
calendar = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$: inputValue.set(value);
|
$: inputValue.set(value);
|
||||||
$: value = $inputValue;
|
$: value = $inputValue;
|
||||||
$: inputValueFrom.set(valueFrom);
|
$: inputValueFrom.set(valueFrom);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue