use-previous
Returns previous value of given state
Source
Docs
Package
Usage
The use-previous hook stores the previous value of a state in a ref.
It returns undefined on the initial render and the previous value of a state after rerender:
Current value:
Previous value: