Use this file to discover all available pages before exploring further.
useDebouncedCallback is a React hook that wraps any callback function and returns a debounced version of it. Unlike useDebounce — which debounces a reactive value — this hook debounces the function call itself, making it ideal for event handlers like onChange, onScroll, or onInput where you want to delay or throttle execution without managing timers manually. The returned function also exposes cancel, flush, and isPending control methods for fine-grained timing control.
The function to debounce. The hook keeps an up-to-date ref of the callback internally, so you can safely pass an inline arrow function without causing the debounce timer to reset on every render.
The quiet period in milliseconds. The callback executes only after this many milliseconds have passed since the last invocation. Defaults to 300. Values below 0 are clamped to 0.
When true the callback executes immediately on the first call of a debounce sequence, before the delay timer starts. Useful for instant feedback on the first interaction. Default: false.
The maximum number of milliseconds to wait before forcing the callback to execute, even if calls are still coming in. Useful for implementing throttle-like behaviour alongside debouncing.
The debounced version of callback. It accepts the same arguments as the original function. In addition to being callable, it exposes three control methods:
The hook stores the latest callback in a ref, so changing the callback between renders never resets the debounce timer. The most recent version is always called.
The debounced function and its control methods are built with useMemo and are stable across renders when delay and options do not change.
On component unmount, any pending timer is automatically cleared to prevent calling callbacks on unmounted components.
If you only need to debounce a value rather than a function, use useDebounce instead.