Component props
- Extend props of an HTML element with custom props
import { ComponentProps } from "react";
type ButtonProps = ComponentProps<"button"> & {
size: "small" | "default"
};
- Infer prop types from the definition of a component
const SubmitButton = (props: { onClick: () => void }) => {
return <button onClick={props.onClick}>Submit</button>;
};
type SubmitButtonProps = ComponentProps<
typeof SubmitButton
>;