Function onMount
- on
Mount <T>(fn): void Type Parameters
Parameters
- fn: (() => NotFunction<T> | Promise<NotFunction<T>> | (() => any))
- (): NotFunction<T> | Promise<NotFunction<T>> | (() => any)
Returns NotFunction<T> | Promise<NotFunction<T>> | (() => any)
Returns void
- fn: (() => NotFunction<T> | Promise<NotFunction<T>> | (() => any))
The
onMount
function schedules a callback to run as soon as the component has been mounted to the DOM. It must be called during the component's initialisation (but doesn't need to live inside the component; it can be called from an external module).If a function is returned synchronously from
onMount
, it will be called when the component is unmounted.onMount
does not run inside a server-side component.https://svelte.dev/docs/svelte#onmount