UNPKG

react-native-flexible-grid

Version:

React Native Flexible Grid is an advanced grid layout system inspired by CSS Grid, designed to facilitate responsive, customizable, and dynamic grid layouts in React Native applications. It supports both responsive and fixed layouts, enabling the creation

27 lines (26 loc) 825 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = require("react"); /** * A hook to throttle function calls. * @param callback The function to throttle. * @param delay The throttle delay in milliseconds. * @returns A throttled version of the provided function. */ const useThrottle = (callback, delay) => { const throttleTimeout = (0, _react.useRef)(null); const throttledFunction = (0, _react.useCallback)((...args) => { if (throttleTimeout.current === null) { callback(...args); throttleTimeout.current = setTimeout(() => { throttleTimeout.current = null; }, delay); } }, [callback, delay]); return throttledFunction; }; var _default = exports.default = useThrottle; //# sourceMappingURL=use-throttle.js.map