UNPKG

@theoplayer/react-native-ui

Version:

A React Native UI for @theoplayer/react-native

18 lines (17 loc) 501 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useThrottledCallback = useThrottledCallback; var _react = require("react"); function useThrottledCallback(cb, delay) { const lastCallRef = (0, _react.useRef)(0); return (0, _react.useCallback)((...args) => { const now = Date.now(); if (now - lastCallRef.current >= delay) { lastCallRef.current = now; cb(...args); } }, [cb, delay]); } //# sourceMappingURL=useThrottledCallback.js.map