Question · JavaScript and React course · Module 12: React and TypeScript

Generics vs Concrete Types

When is it best to use a generic component <T> instead of a component with concrete prop types?

Answer options

  • Only in class components
  • When a component needs to work with different data types while maintaining type safety
  • Always - generics are faster at runtime
  • When a component has no props

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