Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 28 of 56 · Typescript

React Props & State Typing

Duration: 20 minutes

Props Interface

interface CardProps {
  title: string;
  description?: string;
}

const Card: React.FC<CardProps> = ({ title, description }) => (
  <div>
    <h2>{title}</h2>
    {description && <p>{description}</p>}
  </div>
);

State with Union Types

type Status = "idle" | "loading" | "error";
const [status, setStatus] = useState<Status>("idle");

Context Typing

interface ThemeContextProps { dark: boolean; toggle(): void; }
const ThemeContext = React.createContext<ThemeContextProps | undefined>(undefined);

Info

Never expose any in component props – it defeats the purpose of TypeScript.

Previous: TypeScript with React – JSX TypingNext: React Hooks – `useState`, `useEffect` Types