Best practice working with reactive values inside context provider
I did some experiments using solidjs context.
Context as value is not reactive in solid.js.
It's a little different from props that are reactive - if you pass signals as props like
a={a()}
to Child, and access props.a
- a
is reactive.
If I wrap the context value in a function and treat context as Accessor<OriginalContextValue> - it's reactive.
If I use a store it's reactive too (but the update needs to be done differently).
So is it considered good practice to use it with thunk (wrapping in a function)?
2 Replies
I usually do this
so the same as props - you just have to manually create the object, instead of relying on compilation
doing this will merge the two "update channels" in to a single one
which can cause over-updating in downstream computations as you cannot now listen to
a()
selectivelyThank you very much!