import * as React from "react" ; function setRef ( ref ? , value = null ) { if ( ! ref ) return ; if ( typeof ref === "function" ) { ref ( value ) ; } else { ( ref as React . MutableRefObject < any > ) . current = value ; } } example export function useForkRef ( refA ? , refB ? ) { return React . useMemo ( ( ) => { if ( refA == null && refB == null ) { return null ; } return ( value ) => { setRef ( refA , value ) ; setRef ( refB , value ) ; } ; } , [ refA , refB ] ) ; }