Skip to content

Make a store reactive to changes in another store #1586

Answered by dai-shi
feederaccount asked this question in Q&A
Discussion options

You must be logged in to vote

Zustand is unopinionated, and you can do what you can do.
You could use .subscribe() instead of useEffect.

That said, Zustand is not designed for coordinating multiple stores. So, in general, a single big store is preferred, if such coordination is required, like changing both things at once.

If you prefer keeping things small, you may want to try https://github.com/pmndrs/jotai or https://github.com/pmndrs/valtio.

btw, I have an experimental project derive-zustand, but it may not fit your needs.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by feederaccount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants