1 | import { Dispatch, SetStateAction } from 'react';
|
2 | import { UseDebouncedCallbackOptions } from './useDebouncedCallback';
|
3 | /**
|
4 | * Similar to `useState`, except the setter function is debounced by
|
5 | * the specified delay. Unlike `useState`, the returned setter is not "pure" having
|
6 | * the side effect of scheduling an update in a timeout, which makes it unsafe to call
|
7 | * inside of the component render phase.
|
8 | *
|
9 | * ```ts
|
10 | * const [value, setValue] = useDebouncedState('test', 500)
|
11 | *
|
12 | * setValue('test2')
|
13 | * ```
|
14 | *
|
15 | * @param initialState initial state value
|
16 | * @param delayOrOptions The milliseconds delay before a new value is set, or options object
|
17 | */
|
18 | export default function useDebouncedState<T>(initialState: T | (() => T), delayOrOptions: number | UseDebouncedCallbackOptions): [T, Dispatch<SetStateAction<T>>];
|