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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.