use-throttled-effect
Runs an effect throttled when its dependencies change
Source
Package
Usage
use-throttled-effect works like useEffect, but runs the effect at most once per wait
milliseconds while its dependencies keep changing. Use it for effects that follow a stream of
updates, for example scroll position or a slider value:
Drag the slider – the effect samples the value at most once per 500ms
Samples: –
Difference from useEffect
The effect runs immediately on mount and on the first change. Changes during the next wait
milliseconds run it once more at the end of that time with the latest values.
The effect may return a cleanup function. It is called before the next run and on unmount. A pending run is canceled on unmount.
Unlike use-debounced-effect, the hook has no leading and maxWait options.