Put in order · JavaScript and React course · Module 12: React and TypeScript

Creating a Generic Component

Arrange the steps for creating a generic list component in the correct order:

Items to put in order

  • Define a generic props interface: ListProps<T extends HasId>
  • Create a generic component: function List<T extends HasId>(props)
  • Use the component with a concrete type: <List<Planet> items={...} />
  • Define a constraint: interface HasId { id: string | number }

You can check the correct answer by solving this task in the CodeWorlds game.