createEffect is reactive, JSX isn't
I have this code, where I'm accessing props.loading (which is an accessor created from createSignal), and then also accessing it in the JSX via
Show
. The createEffect
reacts properly to the signal being updated, the JSX does not. I'm doing some weird stuff where the signal is created in response to a click, so it's maybe created with a different owner or something, but I didn't think it would matter the owner/tracking context when the signal is created, only when it's accessed. I basically thought that createEffect
should be doing a very similar thing to <Show when={x()}/>
, so I'm confused why one works and one doesn't.
Hoping for an idea of how components "get" reactivity, so that I could understand an issue like this from first principles4 Replies
This component is rendered from a
<Dynamic>
, would that make it lose reactivity somehow? I'm seeing that in the code for Dynamic
, the component is rendered inside an untrack()
call?
https://github.com/solidjs/solid/blob/dbdc27df2246ec05c0e32cf7b461ddbe4223915f/packages/solid/web/src/index.ts#L132No, the
Dynamic
shouldn't affect this, just as the createEffect
, the template is still reactive
You usually don't pass accessors as props though, but call it as you pass it and solid transforms it into a getter, so that could be the reason here. Try passing loading={loading()}
and then consume it as boolean
in your componentcan u make a minimal reproduction of it in the playground.solidjs.com?
this sounds like somewhere in a parent component you're accessing the result of
Show
in a non-reactive manner
though honestly that's pretty difficult to do so it could be something else