@nexusui/components
Version:
These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.
2 lines (1 loc) • 400 B
JavaScript
import{useRef as r,useEffect as t,useCallback as e}from"react";const c=(c,n,u)=>{const o=r(),p=r(c),l=r(n),a=r(u);return t((()=>{p.current=c,l.current=n,a.current=u}),[c,n,u]),e(((...r)=>{const t=void 0,e=a.current&&!o.current;clearTimeout(o.current),o.current=setTimeout((()=>{o.current=null,a.current||p.current.apply(t,r)}),l.current),e&&p.current.apply(t,r)}),[p,l,a])};export{c as useThrottle};