Keep a state whose updates are applied only after the user stops changing it.
This is custom React hooks, you need to follow the Basic Rules when you use it.
The value changes 500ms after the last keystroke.
const useDebouncedState = <T>(
initialValue: T,
wait: number,
options?: { leading?: boolean },
) => [T, (value: T) => void]