Skip to content

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

Open
@ZeikJT

Description

@ZeikJT

Describe the bug

If you store a component in a variable it runs onMount once the element is created, but not necessarily when it's mounted to the actual DOM. If this isn't fixable, might want to update the docs.

Similarly for onCleanup, once you're in this state the cleanup is based on the ancestors.

Your Example Website or App

https://playground.solidjs.com/anonymous/dbcc36b4-44e6-49ed-a7bf-50e376d71016

Steps to Reproduce the Bug or Issue

https://playground.solidjs.com/anonymous/dbcc36b4-44e6-49ed-a7bf-50e376d71016
https://playground.solidjs.com/anonymous/efd63022-a8c2-44fb-842f-51c474b4b959

Expected behavior

As a user, I'd expect onMount and onCleanup to run when the relevant component and elements are inserted into and removed from the DOM itself.

Registers a method that runs after initial rendering is done and the elements are mounted to the page.

https://docs.solidjs.com/reference/lifecycle/on-mount (emphasis mine)

Screenshots or Videos

No response

Platform

All of them I'd assume

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomershelp wantedLooking for assistance on this issuesolidRelated to core Solid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions