UNPKG

@theoplayer/react-native-ui

Version:

A React Native UI for @theoplayer/react-native

12 lines 365 B
import { useCallback, useRef } from 'react'; export function useThrottledCallback(cb, delay) { const lastCallRef = useRef(0); return useCallback((...args) => { const now = Date.now(); if (now - lastCallRef.current >= delay) { lastCallRef.current = now; cb(...args); } }, [cb, delay]); } //# sourceMappingURL=useThrottledCallback.js.map