What is the proxy state pattern (Valtio / Immer) versus immutable state?
Answer
The proxy state pattern and immutable state pattern represent fundamentally different approaches. Immutable state (Redux, Zustand): state never changes — updates create new objects. Enables reference equality checks (prev === next means no change), time-travel debugging (save old state references), and structural sharing. All React state management best practices are built around immutability. Debugging: see exactly what changed between two snapshots. Proxy state (Valtio, MobX, Vue): Proxy intercepts property access and mutation. State appears mutable but reactivity is tracked automatically. Less boilerplate for updates. Familiar for developers from Vue/MobX. Immer's hybrid: writes look mutable, produces immutable results. Best of both worlds — mutating syntax, immutable semantics. Trade-offs: Proxy state is more ergonomic for deeply nested updates. Immutable state is more predictable and debuggable. Proxy-based libraries can have surprising behavior when state is shared across module boundaries (Proxy objects vs plain objects). For large teams, immutable state (enforced by TypeScript readonly types) reduces a class of mutation bugs. For smaller projects, proxy-based Valtio offers excellent DX with minimal ceremony.
Previous
What are the advanced patterns for selector composition?
Next
How do you migrate from Redux to a modern state management solution?
More Redux / State Management Questions
View all →- Advanced How do you architect state management for large-scale React applications?
- Advanced What is Redux-Saga and how does it differ from Thunks?
- Advanced What is XState and state machines in UI development?
- Advanced How does TanStack Query's caching and staleness model work?
- Advanced What are the patterns for sharing state between micro-frontends?