use-debounced-state
Debounces value changes
Source
Docs
PackageIcon
Usage
The use-debounced-state hook debounces value changes.
This can be useful when you want to perform a heavy operation based on React state,
for example, sending a search request. Unlike use-debounced-value, it
is designed to work with uncontrolled components.
Debounced value: [empty string]
Differences from use-debounce-value
- You do not have direct access to the non-debounced value.
- It is used for uncontrolled inputs (
defaultValueprop instead ofvalue), for example, it does not render with every state change like a character typed in an input. - It does not work with custom state providers or props, and it uses
useStateinternally.
Leading update
You can immediately update the value with the first call using { leading: true } options:
Debounced value: [empty string]
Definition
Exported types
The UseDebouncedStateOptions and UseDebouncedStateReturnValue types are exported from the @mantine/hooks package;
you can import them in your application: