Zustand · Concept
Prevent rerenders with useShallow
useShallow helps prevent unnecessary React rerenders when a selector returns a new object or array whose first-level values are unchanged. It compares the computed result shallowly instead of relying only on Object.is.
Last updated
Syntax
useStore(useShallow((state) => computedValue))In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
createselectorObject.iszustand/react/shallowshallow comparison