Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rijvi-mahmud/shaddy/llms.txt
Use this file to discover all available pages before exploring further.
useDebounce is a React hook that delays propagating a value to the rest of your component until the value has stopped changing for a specified number of milliseconds. This is the classic debouncing pattern: instead of reacting to every keystroke or slider movement, you wait for the user to pause before acting. It is the simplest way to avoid hammering an API on every character typed in a search box, or to keep expensive derived computations from running on every render.
Installation
Signature
Parameters
The input value to debounce. Can be any type — string, number, object, array, etc. The generic parameter
T is inferred automatically from the argument you pass.The quiet period in milliseconds. The debounced value updates only after this many milliseconds have passed since the last change to
value. Values below 0 are clamped to 0.Return Value
The debounced copy of
value. It mirrors value exactly but only updates after delay milliseconds of inactivity. On the first render it is initialised to the same value as value.Usage
Debounced Search Input
Debounced Number (Slider)
Notes
- The hook is generic (
<T = any>), so the debounced value’s type exactly matches the input value’s type — no casting needed. - Each time
valuechanges, the internal timer is cleared and restarted. The debounced value only updates when the timer completes without interruption. - Setting
delayto0still defers the update by one event-loop tick (viasetTimeout(fn, 0)), which can be useful for batching updates. - If you need to debounce a function rather than a value, use
useDebouncedCallbackinstead.