Prompt
Write historyReducer(state, action) over the shape { past: [], present, future: [] }:
{ type: 'SET', value }— pushes current present onto past, sets new present, clears future{ type: 'UNDO' }— moves present to future, pops the last past entry into present{ type: 'REDO' }— inverse of UNDO- UNDO with empty past / REDO with empty future return state unchanged
- Pure function — no mutation, no side effects
Hints
Solution
Your Code
15 min