UNPKG

seti-ramesesv1

Version:

Reusable components and context for Next.js apps

22 lines (18 loc) 571 B
import * as React from 'react'; const UNINITIALIZED = {}; /** * A React.useRef() that is initialized lazily with a function. Note that it accepts an optional * initialization argument, so the initialization function doesn't need to be an inline closure. * * @usage * const ref = useLazyRef(sortColumns, columns) */ function useLazyRef(init, initArg) { const ref = React.useRef(UNINITIALIZED); if (ref.current === UNINITIALIZED) { ref.current = init(initArg); } return ref; } export { useLazyRef as default }; //# sourceMappingURL=useLazyRef.js.map