Zust2help -
// Bad — re-renders on any state change const count, increment, user = useStore() // Good — re-renders only when count changes const count = useStore((state) => state.count) const increment = useStore((state) => state.increment) Issue: Event handlers or useEffect closures capture old state.
) ) Issue: LocalStorage or session is not available on the server. zust2help
Select only the needed state.
// store/userStore.js export const useUserStore = create((set) => ( user: null, setUser: ... )) // store/cartStore.js export const useCartStore = create((set) => ( items: [], addItem: ... )) Zustand supports Redux DevTools, persistence, and custom middleware. // Bad — re-renders on any state change
interface BearState bears: number addBear: () => void eatFish: () => void state.count) const increment = useStore((state) =>