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.

6mIntermediate16,398 students
Video thumbnail for Generic components in React

Sign in to watch this lesson

Browsing is free. Create an account to play videos and track your progress.

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.

What this lesson covers

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

This lesson sits in Generics, part of TypeScript for Application Developers. It assumes what came before it and leads directly into the next lesson in the module.

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.

Generic components in React — Skiply