useDebounceValue
Custom hook that returns a debounced version of the provided value, along with a function to update it.
Custom hook that returns a debounced version of the provided value, along with a function to update it.
Usage
import { useDebounceValue } from "@tilt-legal/cubitt-components/utilities/hooks";
const [debouncedValue, updateDebouncedValue] = useDebounceValue(inputValue, 500, { leading: true });API
Signature
declare function useDebounceValue<T>(initialValue: T | (() => T), delay: number, options?: UseDebounceValueOptions<T>): [T, DebouncedState<(value: T) => void>];Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
initialValue | `T | (() => T)` | The value to be debounced. |
delay | number | The delay in milliseconds before the value is updated (default is 500ms). | - |
[options] | object | Optional configurations for the debouncing behavior. | - |
Return Value
| Value | Type | Description |
|---|---|---|
return | [T, DebouncedState<(value: T) => void>] | An array containing the debounced value and the function to update it. |
useDebounceCallback
Custom hook that creates a debounced version of a callback function.
useInterval
Custom hook that creates an interval that invokes a callback function at a specified delay using the [`setInterval API`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval).