Skip to content

Instantly share code, notes, and snippets.

@prezbar
prezbar / .ts
Created September 26, 2025 08:06
Use State / Debounced
/**
* Custom React hook that provides a debounced version of a state value.
*
* @template T - The type of the state value.
* @param initialValue - The initial value of the state.
* @param delay - The debounce delay in milliseconds.
* @returns A tuple containing:
* - The current value.
* - An update function that merges new partial values into the current value.
* - The debounced value, which updates after the specified delay.