Skip to content

useThrottle

Category
Last Changed
1月23日7时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

v3.2.2 on 1/23/2025
301cc - feat: core function support refValue
v3.1.0 on 1/9/2025
a9c9f - feat: add useThrottle and useDebounce function
49422 - feat: add useThrottle and useDebounce function
59615 - feat: add throttle function

Released under the MIT License.