A clean, modern, and fully functional Todo web application built from scratch with React, Vite, and Tailwind CSS. This project was created as a way to master core React concepts, including state management, component architecture, and modern development practices.
- Create Todos: An intuitive form to add new tasks.
- Update Todos: Mark tasks as "complete" or "incomplete" with a single click. The UI updates instantly.
- Delete Todos: Easily remove tasks from your list.
- Modern UI: A clean, responsive design styled with Tailwind CSS, featuring SVG icons for a better user experience.
- Conditional Rendering: A helpful message appears when the todo list is empty.
- Component-Based: Built with a logical, reusable component structure.
- React: The core library for building the user interface.
- Vite: A blazing-fast front-end build tool and development server.
- Tailwind CSS: A utility-first CSS framework for rapid, custom UI development.
To get a local copy up and running, follow these simple steps.
You must have Node.js (which includes npm) installed on your machine.
- Clone the repository:
git clone https://github.com/HemJoshi111/react-todo-app.git
- Navigate to the project directory:
cd YOUR_REPOSITORY_NAME - Install dependencies:
npm install
- Run the development server:
Your app will now be running on
npm run dev
http://localhost:5173(or a similar port).
This project was a deep dive into the fundamental, real-world patterns of React development:
- Component Architecture: The app is broken down into logical components (
App,Header,TodoForm,TodoList,TodoItem) that follow the "Separation of Concerns" principle. - State Management: Used the
useStatehook to manage all application state, including the maintodosarray and the form's input value. - Lifting State Up: This was the core logic pattern. The "source of truth" (
todosstate) lives in theAppcomponent. - Props (Properties):
- Data Flow: Data (like the
todosarray) flows down from parent to child (App->TodoList->TodoItem). - Function Props: Functions (
addTodo,toggleTodo,deleteTodo) are passed down as props to child components, allowing them to send data up to the parent.
- Data Flow: Data (like the
- List Rendering: Used the
.map()method to render a dynamic list ofTodoItemcomponents, passing a uniquekeyprop for each to ensure efficient re-renders. - Conditional Rendering: Used ternary operators to:
- Show a "No todos yet" message if the
todosarray was empty. - Apply conditional Tailwind classes (
line-through,text-gray-400) to items based on theircompletedstatus.
- Show a "No todos yet" message if the
- Event Handling: Used
onSubmitfor the form andonClickfor the buttons to manage user interactions.
