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 27 of 56 · Typescript

TypeScript with React – JSX Typing

Duration: 25 minutes

Create a React + TS project

npx create-react-app my-app --template typescript

Functional Component Props

type GreetingProps = { name: string; age?: number };

const Greeting: React.FC<GreetingProps> = ({ name, age }) => (
  <h1>Hello, {name}{age && ` (${age})`}!</h1>
);

Using useState with Generics

const [count, setCount] = useState<number>(0);

useRef typing a DOM element

const inputRef = useRef<HTMLInputElement>(null);

Info

When using React.FC, the children prop is already defined. If you don’t need it, you can write a plain function component.

Previous: Custom Error TypesNext: React Props & State Typing