Loading...
Loading...
Error: Zustand store updated but UI remains at previous state.Zustand relies on strict reference equality for re-renders. If you return a new object literal in your selector WITHOUT using a shallow equality check, or if your selector is stable while the data is changing, the component will 'miss' the update.
If your selector returns multiple values in an object, you MUST use the shallow middleware.
import { useShallow } from 'zustand/react/shallow';
const { x, y } = useStore(useShallow(s => ({ x: s.x, y: s.y })));Ensure you are returning a new object state, not mutating the existing one.
// ❌ WRONG
set((state) => { state.count++; });
// ✅ CORRECT
set((state) => ({ count: state.count + 1 }));