Creating a basic class component

Let's look at App.tsx, which has been created for us. This is an example of a class component. We're going to create our own class component now. Follow these steps:

  1. Create a file called Confirm.tsx in the src folder, and enter the following into it:
import * as React from "react";class Confirm extends React.Component {  }export default Confirm;

We learned all about classes in Chapter 1, TypeScript Basics. Here we are creating a class that extends the standard Component class from React. Note that we've imported React at the top of our file, and also that we are exporting our class component using a default export at the bottom of our file.

  1. Let's start to implement our Confirm class component now, by creating ...

Get Learn React with TypeScript 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.