useDebounce
#
DescriptionDebounce any state value with this hook.
It often gets used to debounce fetching based upon change of an input field.
#
Usageimport { useState } from 'react';import { useDebounce } from '@springtree/eva-suite-react-hooks';
const Example = () => { const [inputValue, setInputValue] = useState<string | undefined>(); const debouncedInputValue = useDebounce(inputValue, 500);
return ( <> <input type="text" value={inputValue ?? ''} onChange={(event) => setInputValue(event.target.value)} /> <span> {`The debounced value is: ${debouncedValue}`} </span> </> )};
export default Example;