Skip to content
Entangle UI v0.13.0

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.

Args extends unknown[]

(…args) => void

number

UseDebouncedCallbackOptions = {}

DebouncedCallback<Args>

const onResize = useDebouncedCallback(measure, 150);
useEffect(() => {
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
}, [onResize]);