You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Performance Optimization:** Updates that produce no actual changes (empty patches) won't create history entries or trigger subscribers. For example, `setState(state => state)` or conditional updates that don't modify any fields. This prevents memory bloat from no-op operations.
Subscribe to state changes. Returns an unsubscribe function.
@@ -309,6 +311,7 @@ Stick with the default immutable mode for reducer-driven stores (Redux, Zustand)
309
311
### Behavior at a Glance
310
312
311
313
-`setState` keeps the reference stable as long as the current state root is an object. Primitive roots (number, string, `null`) trigger an automatic immutable fallback plus a dev warning.
314
+
- No-op updates (producing empty patches) are optimized away and won't create history entries or notify subscribers.
312
315
-`back`, `forward`, and `go` also mutate in place unless the history entry performs a root-level replacement (patch path `[]`). Those rare steps reassign the reference to keep history correct.
313
316
-`reset` replays a diff from the original initial state, so the observable reference survives a reset.
314
317
-`archive` (manual mode) merges temporary patches and still mutates the live object before saving history.
0 commit comments