Size
0.23 kb
useDebounceFn
A debounce function, reactified.
Ensures that a function is only executed after a specified delay following the last invocation.
Installation
Usage
The useDebounceFn
hook accepts a delay in milliseconds and returns a debounce
function.
All calls are delayed until 1000ms have passed since the last invocation, then only the final call executes.
Override the default delay:
Cancel pending execution:
When the component unmounts, pending executions are automatically canceled.
API Reference
UseDebounceFnReturn
What `useDebounceFn` returns
Prop | Type | Default |
---|---|---|
isPending | boolean | - |
cancel | () => void | - |
debounce | (fn: () => any, delay?: number | undefined) => void | - |