Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useThrottleCallback

A function that runs at most once per interval.

HooksState@gaudi/design-system/hooks/state/use-throttle-callbackView in StorybookSource

Keeps scroll, pointer and resize handlers responsive without running on every event: the first call runs at once and later calls fold into one trailing call with the latest arguments.

Usage

import { useThrottleCallback } from '@gaudi/design-system/hooks';
const onScroll = useThrottleCallback(() => setProgress(readProgress()), 100);

Examples

Throttle pointer moves

Storybook

API

3 options
2 return values

Accessibility

Keep the final state accurate (trailing: true) so progress indicators and announcements end on the real value.

Notes

  • createThrottler(callback, wait, options) is exported for non-React code.