Temporal
Course Description
Catch errors in your code as you type without having to leave your editor! That's the power of using TypeScript with React. Learn to use TypeScript with React components ensuring you have the correct properties. And use the Context API, React Hooks, and type props to build more robust and reliable Typescript applications at scale!
This course and others like it are available as part of our Frontend Masters video subscription.
Preview
CloseWhat They're Saying
Exploring Frontend Masters and it's been an amazing journey! The content is top-notch, and the way industry experts simplify complex concept is phenomenal. I'm thrilled to share that I've just complete the 'React and TypeScript, v2' course by a renowned instructor Steve Kinney. The depth of the concepts explored in the course is truly remarkable.

Priyank S.
React js Developer | Designing Scalable Solutions
Finished React and Typescript v2 by Steve Kinney on Frontend Masters didn't expect to finally gain a deeper understanding of reducers and the context Api so all in all a superb use of my time!

Scott D
WebDevBrum
Doing two simultaneous courses on Frontend Masters. Full Stack for Front-End Engineers by Jem Young and React + TS by Steve Kinney. The quality is incredible of these courses, and the Full stack course is SO INTERESTING!

Aaryan Dewan
aaryandw
Table of Contents
Introduction
Section Duration: 8 minutes
Components
Section Duration: 57 minutes
- Steve begins refactoring a React component to use TypeScript. The file extension is renamed to use a .tsx extension. As types are added to the component, the editor will display errors where type conflicts occur. Errors can also be displayed in the terminal.
API's
Section Duration: 27 minutes
- Steve explains how to add types to state hooks when the data is returned from an API. A type or interface can provide the shape of the state. A default value, such as undefined, should also be provided to handle cases where the data is not loaded or unavailable.
Typing & Refactoring
Section Duration: 1 hour, 51 minutes
- Steve demonstrates template literal types, allowing JavaScript template literals to expand types into many strings via unions. When a union is used in the interpolated position, the type is a set of every possible string literal that each union member could represent.
- Steve introduces a few utility methods to facilitate common type transformations. The Partial utility method creates types from a list of keys from an object. This is useful when updates to an object should match the object's keys, but not all properties are required.
Generics
Section Duration: 59 minutes
- Steve revisits template literals and demonstrates how they can pull keys and values from generics to type actions. A generic can be used to ensure the action type is one of the keys from an object and that the payload for that action uses the correct type.
- Steve demonstrates how generics are used to create type systems. Generics act like variables in a type definition. As a type like "string" is passed to a factory function, that type will dynamically fill the specific types in the returned object.
- Steve uses generics to code a custom createContext method that will throw an error if the context value is not set. This technique eliminates the need to cast the types with the "as" keyword by taking advantage of generics and closure scope.
Wrapping Up
Section Duration: 6 minutes