import { useRef , useEffect } from 'react' ; export function useShareForwardedRef < T > ( forwardedRef ) { const innerRef = useRef < T > ( null ) ; useEffect ( ( ) => { if ( ! forwardedRef ) { return ; } if ( typeof forwardedRef === 'function' ) { forwardedRef ( innerRef . current ) ; return ; } else { forwardedRef . current = innerRef . current ; } } ) ; return innerRef ; }