- Hooks
- Browser hooks
- useDebounce
useDebounce
Delay the execution of function or state update with useDebounce.
use-debounce.tsx
Installation
Copy and paste the following code into your project.
use-debounce.ts
Update the import paths to match your project setup.
Arguments
Name | Type | Description |
---|---|---|
value | any | The value that you want to debounce. This can be of any type. |
delay | number | The delay time in milliseconds. After this amount of time, the latest value is used. |
Return value
Name | Type | Description |
---|---|---|
debouncedValue | any | The debounced value. After the delay time has passed without the value changing, this will be updated to the latest value. |