GoScrobble/web/node_modules/@restart/hooks/cjs/useDebouncedState.d.ts

16 lines
477 B
TypeScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
import { Dispatch, SetStateAction } from 'react';
/**
* Similar to `useState`, except the setter function is debounced by
* the specified delay.
*
* ```ts
* const [value, setValue] = useDebouncedState('test', 500)
*
* setValue('test2')
* ```
*
* @param initialState initial state value
* @param delay The milliseconds delay before a new value is set
*/
export default function useDebouncedState<T>(initialState: T, delay: number): [T, Dispatch<SetStateAction<T>>];