Skip to content

useThrottle

Category
Last Changed
1月23日15时38分
Related

Throttle execution of a function. Especially useful for rate limiting execution of handlers on events like resize and scroll.

Demo

Delay is set to 1000ms for this demo.

Button clicked: 0

Event handler called: 0

Usage

js
import { useThrottle } from 'comuse-core'

const throttledFn = useThrottle(() => {
  // do something, it will be called at most 1 time per second
}, 1000)

window.addEventListener('resize', throttled)

Source

SourceDemoDocs

Changelog

No recent changes

Released under the MIT License.