@thibault.sh/hooks
Version:
A comprehensive collection of React hooks for browser storage, UI interactions, and more
2 lines • 396 B
JavaScript
var react=require('react');function f(t,e){let[u,n]=react.useState(t),o=react.useRef(Date.now());return react.useEffect(()=>{let r=Date.now(),s=r-o.current;if(s>=e)n(t),o.current=r;else {let c=setTimeout(()=>{n(t),o.current=Date.now();},e-s);return ()=>clearTimeout(c)}},[t,e]),u}exports.useThrottle=f;//# sourceMappingURL=useThrottle.cjs.map
//# sourceMappingURL=useThrottle.cjs.map
;