UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

29 lines (26 loc) 576 B
import { c } from 'react-compiler-runtime'; import { useRef, useEffect } from 'react'; function useEffectOnce(callback) { const $ = c(2); const savedCallback = useRef(callback); const called = useRef(false); let t0; let t1; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = () => { if (called.current === true) { return; } called.current = true; savedCallback.current(); }; t1 = []; $[0] = t0; $[1] = t1; } else { t0 = $[0]; t1 = $[1]; } useEffect(t0, t1); } export { useEffectOnce };