Lesson 2.3

Generic components in React

A typed list component should tell you what its render callback receives. Generic props are how a reusable component stays specific at each use.

Duration
7m
Level
Intermediate
Students
16k students

Overview

A typed list component should tell you what its render callback receives. Generic props are how a reusable component stays specific at each use.

In this lesson you will:

  • Type a component over the shape of its items
  • Keep render props and callbacks correctly typed
  • Forward refs without losing the generic parameter

Resources

TypeScript handbook

The official reference for the tools used in this lesson.