ComponentPropsWithRef<T>: T extends (new (props) => Component<any, any>)
    ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
    : PropsWithRef<ComponentProps<T>>

Used to retrieve the props a component accepts with its ref. Can either be passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React component.

Type Parameters

See

React TypeScript Cheatsheet

Example

// Retrieves the props an 'input' element accepts
type InputProps = React.ComponentPropsWithRef<'input'>;

Example

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

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