Get the value a variable had on the previous render.
This is custom React hooks, you need to follow the Basic Rules when you use it.
It is null on the first render.
const usePrevious = <T>(value: T) => T | undefined | null