useDebouncedCallback
useDebouncedCallback<
Args>(fn,delay,options?):DebouncedCallback<Args>
Defined in: src/hooks/useDebounced/useDebouncedCallback.ts:29
Wrap a function so rapid calls collapse into one. By default the call
fires on the trailing edge — pass leading: true to also fire
immediately. maxWait forces a call even when calls keep coming.
The wrapper identity is stable; passing fresh inline functions across renders is safe and does not reset pending timers.
Type Parameters
Args
Args extends unknown[]
Parameters
fn
(…args) => void
delay
number
options?
UseDebouncedCallbackOptions = {}
Returns
DebouncedCallback<Args>
Example
const onResize = useDebouncedCallback(measure, 150);useEffect(() => { window.addEventListener('resize', onResize); return () => window.removeEventListener('resize', onResize);}, [onResize]);