@wojtekmaj/react-hooks
Version:
A collection of React Hooks.
10 lines (9 loc) • 463 B
TypeScript
/**
* Returns a debounced state and a function to update it.
*
* @template T
* @param {T} initialValue The initial value of the state
* @param {number} [debounceTime=250] The delay to wait before updating the state
* @returns {[T, React.Dispatch<React.SetStateAction<T>>]} The debounced state and a function to update it
*/
export default function useDebouncedState<T>(initialValue: T, debounceTime?: number): [T, React.Dispatch<React.SetStateAction<T>>];