import React , { Ref , RefForwardingComponent } from "react" ; /**
 * withForwardRef provides a property called `forwardRef` using
 * the `React.forwardRef` api.
 */ export default function withForwardRef < P extends { forwardRef ? : Ref < any > ; } > ( BaseComponent ) { const forwardRef = ( props , ref ) => ( < BaseComponent { ... props } forwardRef = { ref } / > ) ; return React . forwardRef < any , P > ( forwardRef ) as any ; }