-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn React with TypeScript
By :

In Chapter 1, Getting Started with React, we built an alert component using React. In this section, we will use TypeScript to make the component strongly typed and experience the benefits. We start by adding a type to the alert component’s props and then experiment with defining a type for its state.
We will use Vite to create a project as we did when we first built the alert component. However, this time, we will choose the React and TypeScript template. Carry out these steps:
npm create vite@latest alert -- --template react-ts
In the preceding code snippet, we have specified the project name and template in the command and so won’t be prompted for this information. The react-ts
template has been chosen to create a React and TypeScript project.