File tree Expand file tree Collapse file tree
src/routes/reference/lifecycle Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,18 +37,18 @@ function onMount(fn: () => void): void;
3737- ** Type:** ` () => void `
3838- ** Required:** Yes
3939
40- Function executed once on mount.
40+ Non-tracking function executed once on mount.
4141
4242## Return value
4343
4444` onMount ` does not return a value.
4545
4646## Behavior
4747
48- - Runs once after the initial render.
49- - Does not track reactive dependencies inside ` fn ` .
48+ - On the client, ` onMount ` runs once after the initial render. It does not run during server rendering .
49+ - ` fn ` does not track reactive dependencies.
5050- Internally, ` onMount(fn) ` is equivalent to ` createEffect(() => untrack(fn)) ` .
51- - Runs after refs have been assigned.
51+ - By the time ` onMount ` runs, refs have already been assigned.
5252
5353## Examples
5454
@@ -75,6 +75,7 @@ import { onMount } from "solid-js";
7575
7676function Example() {
7777 onMount (() => {
78+ // Browser-only code
7879 console .log (window .location .pathname );
7980 });
8081
You can’t perform that action at this time.
0 commit comments