How to react to length of store array?
I have a store representing an array:
Elsewhere I render a list based on that array:
pools.length
is always 0, even when I successfully add an element to the pool store. How do I get the value reactively?10 Replies
How did you add the element?
Hmm, that should work, but can you try with
setPools(produce((array)=>{array.push(...)}))
Or maybe CreatePoolViewButton destructures somewhere so you lose reactivity?Nope, no destructuring that I can see and:
has the same effect
So a createEffect console.log also doesnt respond to pools.length?
No it does...
Here's the code for the button where I consitstently get an index value of 0:
If I add this at the top of the button component:
it always comes out 0
Yeah, you destruct props which is a no no
Oh crap!
So sorry
No worries, you can look into eslint plugin to help catch these
It's just so ingrained in me I literally don't see it any more when it's in the function parameters
Thanks for your help and sorry to waste your time