UNPKG

nexle-tvguide-lib

Version:
18 lines (15 loc) 431 B
import {useRef, useEffect} from 'react'; export const useCombinedRefs = (...refs) => { const targetRef = useRef(null); useEffect(() => { refs.forEach((ref) => { if (!ref) return; if (typeof ref === 'function') { ref(targetRef.current); } else { ref.current = targetRef.current; } }); }, [refs]); return targetRef; };