Skip to content
skillbld
Day 12 of 14 30 minTyped propsEventsGeneric components

Add TypeScript to React components. Type props and children, state, events and refs, type reducers with discriminated unions, type a context safely, and write generic components that work with any kind of item.

By the end of today you can

  • Type component props, optional props and children
  • Type useState, useRef and event handlers
  • Type a reducer's actions with a discriminated union
  • Type a context and its custom hook safely
  • Write a generic list component

What's inside

  • 5 sections
  • 2 diagrams and mind maps
  • 4 code examples you can run
  • 5-question quiz
  1. 1Typing props
  2. 2Typing state, refs and events
  3. 3Typing a reducer
  4. 4Typing context
  5. 5Generic components

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free
Day 12: React with TypeScript · React · SkillBld