First, ensure that underscore is installed in your project.
Then, you can use the throttle
function like this:
index.tsx346 chars14 lines
The throttle
function returns a new function that can be called repeatedly, but will only execute the original function at most once every wait
milliseconds.
Note that if the throttled function is called more frequently than the wait
time, the function will simply be called once per wait
period. If you need guarantees about the timing of your function calls, you may want to use the debounce
function instead.
gistlibby LogSnag