UNPKG

@lesnoypudge/utils-react

Version:

lesnoypudge's utils-react

14 lines (13 loc) 278 B
import { useRef } from "react"; const EMPTY_VALUE = {}; const useConst = (factory) => { const ref = useRef(EMPTY_VALUE); if (ref.current === EMPTY_VALUE) { ref.current = factory(); } return ref.current; }; export { useConst }; //# sourceMappingURL=useConst.js.map