Creates a throttled version of a function that only executes at most once per every limit milliseconds.
limit
The returned function includes a .cancel() method to reset the throttle state and clear any active timers.
.cancel()
The function to throttle.
The number of milliseconds to wait between executions.
A throttled function with a .cancel() method.
const handleScroll = throttle(() => console.log("Scrolling..."), 100);// To stop throttling and clear timers:handleScroll.cancel(); Copy
const handleScroll = throttle(() => console.log("Scrolling..."), 100);// To stop throttling and clear timers:handleScroll.cancel();
Creates a throttled version of a function that only executes at most once per every
limitmilliseconds.The returned function includes a
.cancel()method to reset the throttle state and clear any active timers.