Custom Hooks — Intermediate React challenge.
Implement a custom hook that delays propagating a value until a given amount of time has passed without further changes. Useful for search inputs, autosave, and throttled event streams.
function useDebounce<T>(value: T, delay?: number): T
const [q, setQ] = useState("");
const debounced = useDebounce(q, 300);