useThrottledCallback

Create a function that runs at most once per interval, with a trailing call.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

Move the mouse over the box, the position updates at most every 200ms.

APIs

useThrottledCallback

const useThrottledCallback = <A extends unknown[]>(
  callback: (...args: A) => void,
  wait: number,
) => ((...args: A) => void) & { cancel: () => void }
Edit this page on GitHub