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
Section titled “Type Parameters”Args extends unknown[]
Parameters
Section titled “Parameters”(…args) => void
number
options?
Section titled “options?”UseDebouncedCallbackOptions = {}
Returns
Section titled “Returns”DebouncedCallback<Args>
Example
Section titled “Example”const onResize = useDebouncedCallback(measure, 150);useEffect(() => { window.addEventListener('resize', onResize); return () => window.removeEventListener('resize', onResize);}, [onResize]);