Keep a value with its history and move back and forward through it.
This is custom React hooks, you need to follow the Basic Rules when you use it.
Undo and redo the changes of a value.
const useStateHistory = <T>(initialValue: T) => [
T,
{
set: (value: T) => void
back: (steps?: number) => void
forward: (steps?: number) => void
reset: () => void
},
{ history: T[]; current: number },
]