Replies: 3 comments 3 replies
-
It's not very common to create an array of stores, but I don't think it's impossible. However, in that use case, I'd use |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, thank you for providing great example. Is there any solution you found? |
Beta Was this translation helpful? Give feedback.
3 replies
-
See #163 (comment) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This might be an issue with the way I am trying to architect my stores, but I have a use case where I want to have an array of Zustand stores within another store.
Here's a CodeSandbox showing my implementation mostly working: https://codesandbox.io/s/using-zustand-stores-in-an-array-kwpmxc
The issue is in the
Sleuth.tsx
component, where I am trying to get a count of thebear
stores where thebear
s' status property is a certain value.In the demo, if you add a few bears, then either hibernate them individually or all at once, the "Sleeping Bears Count" never changes. The individual
Bear.tsx
components all update to show the "hibernating" status, but thebears
array on thesleuthStore.ts
doesn't seem to update.I thought maybe it was just the
hibernate()
method in thesleuthStore.ts
store, but since the issue also happens when usinghibernate
on an individual bear, I'm at a loss...Beta Was this translation helpful? Give feedback.
All reactions