UNPKG

react-concise-scrollbar

Version:

a React concise scrollbar component with macOS style

22 lines (19 loc) 545 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useThrottle = useThrottle; var _react = require("react"); function useThrottle(func, delay) { var timer = (0, _react.useRef)(); return (0, _react.useCallback)(function () { if (!timer.current) { func(); timer.current = setTimeout(function () { clearTimeout(timer.current); timer.current = undefined; func(); }, delay); } }, [func, delay]); }