You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
13
-
* It must be called during the component's initialisation (but doesn't need to live *inside* the component;
14
-
* it can be called from an external module).
12
+
* `onMount`, like [`$effect`](https://svelte.dev/docs/svelte/$effect), schedules a function to run as soon as the component has been mounted to the DOM.
13
+
* Unlike `$effect`, the provided function only runs once.
15
14
*
16
-
* If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted.
15
+
* It must be called during the component's initialisation (but doesn't need to live _inside_ the component;
16
+
* it can be called from an external module). If a function is returned _synchronously_ from `onMount`,
17
+
* it will be called when the component is unmounted.
17
18
*
18
-
* `onMount` does not run inside [server-side components](https://svelte.dev/docs/svelte/svelte-server#render).
19
-
*
20
-
* `onMount` runs only once. If you need reactivity, you can use [`$effect`](https://svelte.dev/docs/svelte/$effect),
21
-
* which also runs when the component is mounted to the DOM.
19
+
* `onMount` functions do not run during [server-side rendering](https://svelte.dev/docs/svelte/svelte-server#render).
Copy file name to clipboardExpand all lines: packages/svelte/types/index.d.ts
+6-8Lines changed: 6 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -348,16 +348,14 @@ declare module 'svelte' {
348
348
props: Props;
349
349
});
350
350
/**
351
-
* The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
352
-
* It must be called during the component's initialisation (but doesn't need to live *inside* the component;
353
-
* it can be called from an external module).
351
+
* `onMount`, like [`$effect`](https://svelte.dev/docs/svelte/$effect), schedules a function to run as soon as the component has been mounted to the DOM.
352
+
* Unlike `$effect`, the provided function only runs once.
354
353
*
355
-
* If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted.
354
+
* It must be called during the component's initialisation (but doesn't need to live _inside_ the component;
355
+
* it can be called from an external module). If a function is returned _synchronously_ from `onMount`,
356
+
* it will be called when the component is unmounted.
356
357
*
357
-
* `onMount` does not run inside [server-side components](https://svelte.dev/docs/svelte/svelte-server#render).
358
-
*
359
-
* `onMount` runs only once. If you need reactivity, you can use [`$effect`](https://svelte.dev/docs/svelte/$effect),
360
-
* which also runs when the component is mounted to the DOM.
358
+
* `onMount` functions do not run during [server-side rendering](https://svelte.dev/docs/svelte/svelte-server#render).
0 commit comments