Use TypeScript to Type a React Class Component

Share this video with your friends

Send Tweet

For older applications, it's likely that you have some Class components. TypeScript works a little differently with these. The React.Component class is a generic class and it takes the props type as its first type argument. We will write out an alias for our props that I'll pass in the type argument space for the class. Child classes can also implement their own various methods for overriding parent methods, we'll also want to explicitly type the props in our constructor.

With that, you've finished my course! Congratulations and thank you for taking it!