They are shown when you run the tests. Until then they appear as a hidden requirement.
Make Undo and Redo work in a small pixel editor, keeping the drawing and its history in a reducer. You practice useReducer and state that has to stay coherent.
Undo, Redo and Clear buttons (they stay in view while the board scrolls) and the 8×8 board (cells A1 to H8).useReducer: { type: "paint", row, column, color } when a cell is clicked, { type: "clear" }, { type: "undo" } and { type: "redo" }. The reducer is empty: it returns the state as it is.emptyBoard() returns a new empty board: 8 rows of 8 cells, each null or a color name.C4: Red, C4: empty), the Board section and the texts of the buttons and the colors: the tests use them.Undo takes the board back one change; Redo brings back the board you undid, one change at a time.Undo is disabled when there is nothing to undo, and Redo when there is nothing to redo.Clear empties the whole board as a single change: one Undo brings the drawing back.Clear on an empty board) is not a change: Undo and Redo behave as if it never happened.Undo remembers the last 10 changes; older ones can no longer be undone.A1 and B1 and press Undo → only A1 is painted, and Redo is enabled.Redo → B1 is painted again.Clear and then Undo → the whole drawing comes back.Keep three things in the reducer: the boards before the current one, the current board, and the boards you undid. Whether Undo and Redo are enabled follows from them.
A board that is in the history must never change afterwards. Build each new board with map, row by row.
When you record a change, think about what Redo should still offer once you draw something new.
useReducer: one function that handles every change of the state.The console is empty
Run your code with Ctrl+S
This console starts empty every time the preview loads. The browser's DevTools console keeps the messages with Preserve log.