useDebounceValue
Custom hook that returns a debounced version of the provided value, along with a function to update it.
Installation
npx sse-tool add use-debounce-value
npm install sse-hooks
Usage
import { useDebounceValue } from "./{hooks file}";
const [debouncedValue, updateDebouncedValue] = useDebounceValue(
inputValue,
500,
{ leading: true },
);
import { useDebounceValue } from "sse-hooks";
const [debouncedValue, updateDebouncedValue] = useDebounceValue(
inputValue,
500,
{ leading: true },
);
API
Parameters
| Name | Type | Description |
| :----------- | :------------------------ | :------------------------------------------------------------------------ | -------------------------- |
| initialValue | T | Function | The value to be debounced. |
| delay | number | The delay in milliseconds before the value is updated (default is 500ms). |
| options | UseDebounceValueOptions | Optional configurations for the debouncing behavior. |
Return Value
Returns any.
An array containing the debounced value and the function to update it.