Engrain by ByteRush

TS.08.02 Mid-level

Generic and polymorphic components

Comes up in: React, Coding

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • generic List<T>/Select<T>
  • polymorphic as prop and its typing cost
  • discriminated props (either href or onClick)

Words you will know

polymorphic componentdiscriminated props

What you will practise

  • typed Select<T>
  • Button | Link union props

Interview questions this answers

  • How would you type a component that renders either a link or a button?