How to Extract the Props Type of a React Component
Get the props type of any React component in TypeScript 6 with ComponentProps, ComponentPropsWithoutRef and infer, for wrappers, HTML tags and generics.

Sooner or later you wrap a component that you do not own. A design system exports Button without exporting its props interface, a library gives you a function component and nothing else, or you want a thin wrapper around <input> that accepts every attribute the real element does. In each case you need the props type of a React component without redeclaring it. This post shows how to extract the props type of a React component with React.ComponentProps and its relatives, how to read props out of a component type with infer, and how to handle refs, generics and HTML elements. The examples use React 19 types with TypeScript 6.x, and they apply to the native TypeScript 7 compiler as well. The helper types are documented in the React TypeScript guide.
ComponentProps for a component
React.ComponentProps<T> takes a component type or an intrinsic element name and returns its props. For a function component, you pass typeof the component.
import type { ComponentProps } from "react";
function Button(props: { label: string; onPress?: () => void }) {
return <button onClick={props.onPress}>{props.label}</button>;
}
type ButtonProps = ComponentProps<typeof Button>;
const props: ButtonProps = { label: "Save" };
console.log(props.label);SaveButtonProps is { label: string; onPress?: () => void }. The component is the single source of truth, and any type derived from it follows when the component changes. That is the point of extracting instead of copying: a copied interface is correct on the day you write it and wrong some time later.
The typeof is needed because Button is a value, and ComponentProps expects a type. Without it, the compiler complains that Button refers to a value but is being used as a type.
Wrapping a component
The most common use is a wrapper that adds one prop and forwards the rest.
import type { ComponentProps } from "react";
import { Button } from "./button.tsx";
type Props = ComponentProps<typeof Button> & { loading?: boolean };
export function LoadingButton({ loading, label, ...rest }: Props) {
return <Button {...rest} label={loading ? "Saving" : label} />;
}The intersection keeps every prop of Button and adds loading. If Button later gains a required variant prop, LoadingButton callers see the new requirement immediately, with no change to the wrapper. If you would rather replace a prop than extend it, use Omit<ComponentProps<typeof Button>, "label"> & { label: number }, because an intersection of two different types for the same key produces never.
HTML elements
For intrinsic elements, pass the tag name as a string literal type.
import type { ComponentProps } from "react";
type InputProps = ComponentProps<"input"> & { label: string };
export function Field({ label, ...rest }: InputProps) {
return (
<label>
{label}
<input {...rest} />
</label>
);
}ComponentProps<"input"> is every attribute of the input element as React types it, including value, onChange, type, disabled and the ref property. A caller can write <Field label="Email" type="email" required /> with full checking, and the wrapper stays a few lines long.
Refs: ComponentPropsWithoutRef and ComponentPropsWithRef
There are three related types, and the difference is about the ref key.
import type {
ComponentProps,
ComponentPropsWithRef,
ComponentPropsWithoutRef,
} from "react";
type A = ComponentProps<"button">;
type B = ComponentPropsWithRef<"button">;
type C = ComponentPropsWithoutRef<"button">;
const c: C = { type: "submit", disabled: false };
console.log(c.type);submitComponentPropsWithoutRef removes ref from the result. That is the right choice for a wrapper that does not forward a ref, because including ref in the props type would promise something the component does not do. ComponentPropsWithRef keeps the ref and is the choice for a component that forwards it.
In React 19, function components receive ref as an ordinary prop, so a function component can accept it without forwardRef. In older code that wraps a class component or uses forwardRef, the distinction between the three helpers matters more. When unsure, start with ComponentPropsWithoutRef and add the ref deliberately.
Reading props with infer
You can also pull the props out of a component type with a conditional type. This is useful when you build your own utility.
import type { JSXElementConstructor } from "react";
type PropsOf<C> = C extends JSXElementConstructor<infer P> ? P : never;
function Badge(props: { text: string }) {
return <span>{props.text}</span>;
}
type BadgeProps = PropsOf<typeof Badge>;
const b: BadgeProps = { text: "new" };
console.log(b.text);newJSXElementConstructor<P> is the type of anything React can render as an element, a function or a class. Matching against it with infer P gives the same answer as ComponentProps. In practice ComponentProps is shorter and already handles intrinsic elements, so write your own only when you need to change its behavior.
Generic components
A generic component loses its type arguments when you take typeof it. The props are computed with the constraint of each type parameter.
import type { ComponentProps, ReactNode } from "react";
function List<T>(props: { items: T[]; render: (item: T) => ReactNode }) {
return <ul>{props.items.map((item) => props.render(item))}</ul>;
}
type ListProps = ComponentProps<typeof List>;
const p: ListProps = { items: [1, "a"], render: (i) => String(i) };
console.log(p.items.length);2Here T becomes unknown, so items is unknown[]. To fix the argument, use an instantiation expression: ComponentProps<typeof List<string>>. That gives items: string[] and render: (item: string) => ReactNode.
Picking individual props
Once you have the props type, indexed access pulls out one prop.
import type { ComponentProps } from "react";
import { Button } from "./button.tsx";
type OnPress = ComponentProps<typeof Button>["onPress"];
const handler: OnPress = () => console.log("pressed");
handler?.();pressedOnPress is (() => void) | undefined, because the prop is optional. Use NonNullable if you want only the function type. This is handy when you need to type a callback elsewhere that must match the component's expectation exactly.
Things to watch
The first thing is that extracting props couples your code to the component's internals. If a library changes a prop name, your derived types change with it, which is usually what you want. If you want a stable public type, declare your own interface and make the wrapper convert.
The second is children. In React 19 types, children is not added automatically to function components. A component that renders children has to declare the prop, and ComponentProps reports only what is declared. If a wrapper does not accept children, it will not appear in the extracted type.
The third is class components. ComponentProps<typeof MyClass> works, and it reads the props from the class's type parameters, so no special handling is needed.
Props of a component that is passed as a prop
Higher order patterns take a component as an argument and need its props in the signature. A function that renders any component with a default prop is a good example.
import type { ComponentType } from "react";
export function withDefaults<P extends object>(
Component: ComponentType<P>,
defaults: Partial<P>,
) {
return function Wrapped(props: Omit<P, keyof typeof defaults> & Partial<P>) {
const merged = { ...defaults, ...props } as P;
return <Component {...merged} />;
};
}Here the props type is not extracted with ComponentProps at all. The generic parameter P captures it from the ComponentType<P> argument, which is the cleaner route when you are already inside a generic function. Use ComponentProps<typeof X> when you hold a concrete component and need a type alias, and use a generic parameter when the component arrives as an argument. The cast in the middle is the honest cost of spreading a partial into a full props object, and it is contained in one place.
Keeping wrappers honest
A wrapper that accepts all props of the inner component should pass them all along. A mistake that comes up in code review is a wrapper that accepts ComponentProps<"input"> but then drops half of it by destructuring only the props it knows. The type says every attribute is supported, and the run time ignores most of them.
The remedy is the rest pattern shown above: take the few props you handle yourself and spread the rest onto the inner element. If you need to override a prop that the caller may also pass, put your value after the spread so that yours wins, or before it so the caller wins, and decide which behavior you promise. A lint rule such as the React hooks plugin will not catch this, so it is worth a short test that renders the wrapper with an unusual attribute and checks that it reaches the DOM.
For design systems that publish wrappers as a package, export the derived type under a name, for example export type ButtonProps = ComponentProps<typeof Button>. Consumers then import the alias instead of repeating the extraction, and you have one place to change if you decide to pin the type by hand later.


