Throttle and Debounce


Uncategorized

Updated Aug 22nd, 2021

Good article here. Video in RFTROU course as well.

Lodash is a pretty large package so just pull out what you need.

useMemo instead of useCallback

When tearing down the listener you may need to teardown the throttle as well? For example the lodash.debounce library provides debouncedCallback.cancel() to cancel any scheduled calls.

I’m not sure if the above is needed if you are removing the event listener in the typical way with a return function.