Skip to content
public-library›Rules›Zustand›Update store state functionally and immutably

Update store state functionally and immutably

When new state depends on current state, pass a function to set, and return new objects and arrays for anything that changed. Mutate state directly only inside a store wrapped in the immer middleware.

In the full rule