UNPKG

mutoid

Version:

Reactive library for data fetching, caching, state management

13 lines (12 loc) 291 B
import { useRef } from 'react'; const useLazyRef = (initialValFunc) => { const ref = useRef(null); if (ref.current === null) { ref.current = initialValFunc(); } return ref; }; export function useStore(s) { const store = useLazyRef(s); return store.current; }