0Pricing
TypeScript Academy · Lesson

Typing React Component Props

Define prop interfaces and use FC vs explicit return types.

Welcome

This lesson covers Typing React Component Props in TypeScript with React.

Component Props Interface

Define a props interface for React components to document and enforce the component API.
interface ButtonProps {
  label: string;
  onClick: () => void;
  disabled?: boolean;
}

function Button({ label, onClick, disabled }: ButtonProps) {
  return <button onClick={onClick} disabled={disabled}>{label}</button>;
}

All lessons in this course

  1. Typing React Component Props
  2. Typing useState and useReducer
  3. Typing useRef and Event Handlers
  4. Generic Components and forwardRef
← Back to TypeScript Academy