Skip to content

Why doesn't Zustand incorporate Immer for a cleaner API? #738

Closed Answered by dai-shi
rodrigocfd asked this question in Ideas
Discussion options

You must be logged in to vote

While I personally prefer produce (to me, it's more explicit with produce and draft, not boilerplatey at all), zustand can be used with immer middleware described in https://github.com/pmndrs/zustand#middleware. I think many people are using zustand with immer.

And, my general recommendation for mutable state is valtio instead of zustand+immer combo. With zustand, I started promoting some other solutions with more functional and immutable approaches: https://github.com/pmndrs/zustand/wiki/Updating-nested-state-object-values

That said, people like using zustand with immer, and it's totally a valid solution.
So, we will probably consider adding the official immer middleware in zustand v4.
T…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rodrigocfd
Comment options

Answer selected by rodrigocfd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants