foxact
Version:
React Hooks/Utils done right. For browser, SSR, and React Server Components.
1 lines • 459 B
JavaScript
import e,{useEffect as n,useLayoutEffect as t,useRef as r,useCallback as o}from"react";const c="undefined"==typeof window?n:e.useInsertionEffect||t;function f(e){const n=r(u);return c(()=>{n.current=e},[e]),o(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,n.current)(...t)},[])}function u(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}export{f as useStableHandler};