Create Todo in React JS with typescript?

Jul 18

Creating a to-do application in ReactJS is a great first step towards upskilling. However, incorporating TypeScript into your project will also be beneficial for improving your TypeScript skills.

This blog post will teach you how to create a basic to-do app using TypeScript. The app will include essential features such as:

Getting Started With Vite.

npm create vite@latest
Enter fullscreen mode Exit fullscreen mode
npm install
Enter fullscreen mode Exit fullscreen mode
npm run dev
Enter fullscreen mode Exit fullscreen mode

Now the basic folder structure will look like this.

Do not worry in case you have any additional files.
I have set up the tailwind CSS if you don't know how to set up tailwind CSS in React JS click here.

Image description

Here are the components/modules we are going to develop:

Create components/Navbar.tsx

Attach the navbar in app.tsx

Image description

Create components/Form.tsx

Image description

** However there is a problem in this code. **

Image description

fix:

Add onClick functionality

Image description

Image description

Import Form in App.jsx

Image description

Create a global state of tasks array

Image description

Form.tsx
Image description

Create components/Todos.tsx

Final app.jsx

Image description

Output

Image description