UNPKG

477 BTypeScriptView Raw
1import { Dispatch, SetStateAction } from 'react';
2/**
3 * Similar to `useState`, except the setter function is debounced by
4 * the specified delay.
5 *
6 * ```ts
7 * const [value, setValue] = useDebouncedState('test', 500)
8 *
9 * setValue('test2')
10 * ```
11 *
12 * @param initialState initial state value
13 * @param delay The milliseconds delay before a new value is set
14 */
15export default function useDebouncedState<T>(initialState: T, delay: number): [T, Dispatch<SetStateAction<T>>];