UNPKG

@i-novus/ui-core

Version:

Базовые UI компоненты

18 lines (17 loc) 450 B
/* eslint-disable no-param-reassign */ import { useEffect, useRef } from 'react'; export const useForwardedRef = (ref) => { const internalRef = useRef(null); useEffect(() => { if (!ref) { return; } if (typeof ref === 'function') { ref(internalRef.current); } else { ref.current = internalRef.current; } }, [ref, internalRef]); return internalRef; };