Skip to content

Commit d59ca63

Browse files
Merge branch 'main' into docs/link-components-to-reference
2 parents d585c99 + 4317d3a commit d59ca63

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/routes/reference/lifecycle/on-mount.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ Non-tracking function executed once on mount.
5252
- By the time `onMount` runs, refs have already been assigned.
5353
- Returning a function from `fn` does not register cleanup. Use [`onCleanup`](/reference/lifecycle/on-cleanup) inside `onMount` when cleanup is needed.
5454

55+
:::note
56+
"Mounted" in Solid refers to when a component is rendered within the reactive tree, not when it is physically inserted into the DOM.
57+
If you store JSX in a variable before conditionally rendering it, `onMount` runs when that JSX is evaluated, even if the elements have not yet been added to the visible page.
58+
Similarly, [`onCleanup`](/reference/lifecycle/on-cleanup) runs based on the reactive ownership tree rather than DOM removal.
59+
60+
For cases where you need to detect actual DOM insertion or removal, consider using a [`ref`](/concepts/refs) callback or the [Lifecycle primitives from solid-primitives](https://github.com/solidjs-community/solid-primitives/tree/main/packages/lifecycle).
61+
:::
62+
5563
## Examples
5664

5765
### Access a ref after mount

0 commit comments

Comments
 (0)