This is my simple To-Do List application built with React and TypeScript. Nice and simple The application allows users to add, edit, delete, and mark tasks as completed. The application is basic in it's format but demonstrates state management, CRUD operations, and local storage. For data persistence I opted for local storage use, so your tasks will be saved even after you refresh the page or close the browser.
-
TodoApp Component:
- This is the main component that holds the state and manages the to-do list.
- It includes states for
todos,text, andplaceholder. - It uses
useEffectto load tasks from local storage and save tasks to local storage whenever thetodosstate changes. - It includes functions to add, edit, delete, and toggle the completion status of tasks.
-
TodoForm Component:
- This component handles adding new to-do items.
- It includes an input field for entering the task text and a button to submit the form.
- The input field's placeholder text dynamically updates based on the number of tasks.
-
TodoList Component:
- This component renders the list of to-dos.
- It receives the list of tasks and functions to edit, delete, and toggle tasks from the
TodoAppcomponent.
-
TodoItem Component:
- This component represents a single to-do item.
- It includes options to edit the task text, delete the task, and toggle its completion status.
- The
todosstate holds the list of tasks, each represented by an object withid,text, andcompletedproperties. - The
textstate holds the current input value for the new task. - The
placeholderstate dynamically updates the placeholder text in the input field based on the number of tasks.
- The application uses local storage to persist tasks across browser sessions.
- When the application loads, it fetches tasks from local storage and updates the
todosstate. - Whenever the
todosstate changes, it updates the local storage with the current list of tasks.
- The
placeholderstate starts with the value "Enter your first task". - After a task is added, it updates to "Enter your next task", providing a clear guide for the user.
To get started with this project, follow these steps:
- Node.js and npm installed on your machine.
- Clone the repository:
git clone https://github.com/your-username/todo-list-app.git
- Navigate to project directory:
cd todo-list-app - Install dependencies:
npm install
- Start dev server:
npm start
Once you have the server running, you can access the application at http://localhost:3000. Very simple stuff and from there, you can start adding, editing, deleting, and marking tasks as completed.
This is a very simple application, that I will iteratively update as I continue to build a more solid proficiency in TypeScript. If you have any suggestions or improvements where I can refactor code to more ideal syntaxes, please feel free to open an issue or submit a pull request. Or reach out to me below...
- GitHub: https://github.com/LDMasina
- Instagram: https://instagram.com/lancemasina
- LinkedIn: https://linkedin.com/in/lancemasina