← Code LabReact Native0/50 solved · 0%
Hooks · easy

13. usePrevious logic

The core comparison behind a usePrevious hook.

Write `trackPrevious(history, nextValue)` returning `[newHistory, previousValue]` where `newHistory` is `history` with `nextValue` appended, and `previousValue` is the last element of the original `history` (or `undefined`).
Required in your answer: history.length