useDebounce
React hooks that debounce value
Usage
Live Editor
function Demo() { const [value, setValue] = useState<string>(""); const debouncedValue = useDebounce(value, 500); return ( <div> <input value={value} onChange={e => setValue(e.target.value)} placeholder="Typed value" style={{ width: 280 }} /> <p style={{ marginTop: 16 }}>DebouncedValue: {debouncedValue}</p> </div> ); };
Result
Loading...
API
useDebounce
Returns
T
Arguments
Argument | Description | Type | DefaultValue |
---|---|---|---|
value | the value need to debounce | T (Required) | - |
wait | wait time | number | undefined | - |
options | options passed to lodash.debounce | _.DebounceSettings | undefined | - |