Skip to content

Commit e6fc4e2

Browse files
committed
update onMount docs
1 parent 46b2479 commit e6fc4e2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/svelte/src/index-client.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { legacy_mode_flag } from './internal/flags/index.js';
1717
*
1818
* `onMount` does not run inside [server-side components](https://svelte.dev/docs/svelte/svelte-server#render).
1919
*
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.
22+
*
2023
* @template T
2124
* @param {() => NotFunction<T> | Promise<NotFunction<T>> | (() => any)} fn
2225
* @returns {void}

packages/svelte/types/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ declare module 'svelte' {
356356
*
357357
* `onMount` does not run inside [server-side components](https://svelte.dev/docs/svelte/svelte-server#render).
358358
*
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.
361+
*
359362
* */
360363
export function onMount<T>(fn: () => NotFunction<T> | Promise<NotFunction<T>> | (() => any)): void;
361364
/**

0 commit comments

Comments
 (0)