Event Types, Refs, and Context Typing
Type common React pieces: event handlers, element refs, and context values. Use JSDoc to resemble TypeScript while keeping code runnable.
Why type events/refs/context?
Goal: Type everyday React pieces.
- Events: click/change handlers
- Refs: DOM access without re-render
- Context: typed value across the tree
Key ideas
- Event handlers receive a typed event object.
- Refs store a DOM node or any mutable value.
- Context uses a typed shape to avoid prop drilling.
All lessons in this course
- Props Typing & Generics for Reusable Components
- Event Types, Refs, and Context Typing
- Migrating Incrementally