State Management · Junior · Question 35 of 75
How do you update state in Zustand?
- ✓Correct answer: Call
setinside an action:set((s) => ({ count: s.count + 1 })) - 2Assign directly:
useStore.count = 5 - 3Dispatch an action object with a
typefield
Explanation
set merges the returned object into the state at the top level (one level deep). Actions are usually defined right in the store, so components just call inc().