UseDebouncedValue
Debounce value changes
Usage
Code EditorCopyimport { useDebouncedValue } from '@erudilabs/alma'
const [value, setValue] = useState('')
const [debounced] = useDebouncedValue(value, 200)
Value:
Debounced state:
Code EditorCopy<> <TextInput name="debounced-value-demo-input" label="Enter some text here" placeholder="Enter value to see debounce effect" defaultValue={value} onChange={(event) => setValue(event.currentTarget.value)} /> <div className="mt-4"> <p>Value: {value}</p> <p>Debounced state: {debounced}</p> </div> </>
Definition
Code EditorCopyfunction useDebouncedValue<T = any>( value: T, wait: number, ): readonly [T, () => void];