Sequence NODE_180
Medium

Type React Component Props with TypeScript

TypeScript
React
Technical Specification

Define a Props type for a Button component with label (string), onClick (function), and optional variant.

Input/Output Samples
Input:<Button label='Save' onClick={...} />
Output:Type-safe props
Optimal Logic Path
type ButtonVariant = "primary" | "secondary" | "ghost";

type ButtonProps = {
  label: string;
  onClick: () => void;
  variant?: ButtonVariant;
};
Architectural Deep-Dive
Typing React props with TS helps catch missing or invalid props at compile time instead of runtime.