Keep a number with increment, decrement, set and reset handlers, optionally clamped to a range.
This is custom React hooks, you need to follow the Basic Rules when you use it.
The value stays between min and max.
const useCounter = (
initialValue?: number,
options?: { min?: number; max?: number },
) => [
number,
{
increment: () => void
decrement: () => void
set: (value: number) => void
reset: () => void
},
]