Design Patterns · Middle · Question 14 of 75
Why does immutable state simplify the Memento pattern?
- ✓Correct answer: Old versions don't change, so a memento is just a reference to a previous object
- 2Immutable objects are saved to
localStorageautomatically - 3Immutability forbids undo, so mementos aren't needed
Explanation
With mutations, a memento requires a deep copy. With immutable updates (spread, Immer), unchanged parts are reused (structural sharing), and change history costs almost nothing. That's how time travel in Redux DevTools works.