Skip to content

Clarify that onMount/onCleanup are reactive-tree based#1519

Open
singhvishalkr wants to merge 1 commit into
solidjs:mainfrom
singhvishalkr:docs-1167-onmount-clarification
Open

Clarify that onMount/onCleanup are reactive-tree based#1519
singhvishalkr wants to merge 1 commit into
solidjs:mainfrom
singhvishalkr:docs-1167-onmount-clarification

Conversation

@singhvishalkr
Copy link
Copy Markdown

Users sometimes expect onMount to fire when a component is literally inserted into the DOM, but it actually runs when the component is created within the reactive tree. This distinction matters when JSX is stored in a variable before being conditionally rendered.

I added a note to the onMount reference page explaining:

  • The 'mounted' term refers to the reactive tree, not DOM insertion
  • onCleanup follows the same pattern
  • Links to solid-primitives lifecycle package for DOM-based detection

As Ryan confirmed on the issue, this is by design. The docs should reflect this clearly.

Closes #1167

Co-authored-by: Cursor <cursoragent@cursor.com>
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 16, 2026

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 9a196ac
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/6a081713b535080008722e96
😎 Deploy Preview https://deploy-preview-1519--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onMount/onCleanup not based on when component is added-to/removed-from DOM

1 participant