UNPKG

@chayns-components/core

Version:

A set of beautiful React components for developing your own applications with chayns.

20 lines 659 B
import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'; export const useCombinedRefs = (...refs) => useCallback(element => { refs.forEach(ref => { if (!ref) return; if (typeof ref === 'function') { ref(element); } else if (typeof ref === 'object' && ref !== null) { ref.current = element; } }); }, [refs]); const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; export const useInitialRenderRef = initialValue => { const ref = useRef(initialValue); useIsomorphicLayoutEffect(() => { ref.current = false; }, []); return ref; }; //# sourceMappingURL=ref.js.map