Skip to content
Discussion options

You must be logged in to vote

whether there's a function similar to on_mount

Note that onMount in Solid is also just an effect and does not necessarily run after the component is actually mounted. That's why the example is helpful: leptos_router is effectively doing something similar to the playground example with conditional rendering above, in which the component is rendered, and elements are created, and effects run -- but the elements are not yet actually connected to the DOM.

If you're trying to get access to a particular element (the equivalent of getElementById) then using a NodeRef is indeed the correct way to do it. (This has the benefit of giving you better types than .get_element_by_id() as well.)

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@sodekim
Comment options

@gbj
Comment options

gbj Nov 23, 2025
Maintainer

@sodekim
Comment options

@gbj
Comment options

gbj Nov 24, 2025
Maintainer

Answer selected by sodekim
@sodekim
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants