Type alias CustomComponentPropsWithRef<T>

CustomComponentPropsWithRef<T>: T extends (new (props) => Component<any, any>)
    ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
    : T extends ((props, legacyContext?) => ReactNode)
        ? PropsWithRef<P>
        : never

Used to retrieve the props a custom component accepts with its ref.

Unlike ComponentPropsWithRef, this only works with custom components, i.e. components you define yourself. This is to improve type-checking performance.

Type Parameters

Example

const MyComponent = (props: { foo: number, bar: string }) => <div />;

// Retrieves the props 'MyComponent' accepts
type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;