TypeScript for Application Developers
LESSON 2.3

Generic components in React

Learn key techniques and workflows in TypeScript for Application Developers.

6m
intermediate
16,398 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

Pro Tip

If a reusable component takes items and hands them back to a callback, it wants a type parameter.

Resources