Skip to content

Using signal outside of component. #397

Answered by ryansolid
codart1 asked this question in Q&A
Discussion options

You must be logged in to vote

This thread probably has the best explanation:
#242

The basic of it is while it isn't restricted to components, Solid's reactivity is built with frameworks in mind so it has automatic disposal and scheduling so it needs to run inside a Reactive Root. It isn't necessary to be components but it means that there is a wrapper. I hide that wrapper inside Solid's render function.

It is more than disposal though too since it is how we manage synchronous scheduling. Like wrapping your whole example in a createRoot would only log 8 (since effects are scheduled to the end). If you just want to play around to get a feel for the reactivity without worrying about components, check out this codesandbox:

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
4 replies
@mdovn
Comment options

@mdovn
Comment options

@mdovn
Comment options

@ryansolid
Comment options

Answer selected by ryansolid
Comment options

You must be logged in to vote
1 reply
@ryansolid
Comment options

Comment options

You must be logged in to vote
2 replies
@ryansolid
Comment options

@astoilkov
Comment options

Comment options

You must be logged in to vote
1 reply
@drecdroid
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
8 participants