use-debounced-effect
Runs an effect debounced when its dependencies change
Source
Package
Usage
use-debounced-effect works like useEffect, but the effect runs only after its
dependencies stop changing for the given delay. Use it for side effects that
depend on rapidly changing values, for example fetching search results:
Effect runs: 0
Last searched: –
Difference from useEffect
The effect does not run immediately on mount, it runs delay milliseconds after the mount
and after each dependencies change. Set the leading option to run it immediately.
The effect may return a cleanup function. It is called before the next run and on unmount.
Options
The third argument is either a delay number or an options object:
Definition
Exported types
UseDebouncedEffectOptions type is exported from the @mantine/hooks package,
you can import it in your application: