This documentation provides an overview of the "To-Do List" app created using React. The app allows users to add tasks to a list, delete tasks, and persists task data using local storage.
- Adding Tasks: Users can enter a new task in the input field and click the "Add Task" button to add it to the list.
- Deleting Tasks: Each task in the list is accompanied by a "Delete" button. Clicking this button removes the corresponding task from the list.
- Local Storage: Task data is persisted using local storage, ensuring that tasks are retained even after the user closes or refreshes the page.
The app is structured using two main components:
-
App
Component:- Manages the state of tasks and the new task input.
- Utilizes the
useEffect
hook to load and save tasks to local storage. - Renders the input field, "Add Task" button, and the list of tasks.
-
Task
Component:- Accepts
task
andonDelete
as props. - Renders an individual task along with a "Delete" button.
- Calls the
onDelete
function when the "Delete" button is clicked.
- Accepts
Local storage is used to store and retrieve task data between sessions. The useEffect
hook is used to manage the interaction with local storage. Tasks are loaded from local storage when the app initially loads, and they are saved to local storage whenever the tasks state changes.
Styling for the app is done using CSS. The app is centered on the page, and tasks are displayed in a list format. Each task has a border at the bottom and is accompanied by a "Delete" button for removal.
- Ensure you have Node.js and npm installed.
- Clone the repository or create a new React app using
npx create-react-app todo-list-app
. - Replace the content of
src/App.js
with the code provided in the documentation. - Update the
src/Task.js
andsrc/App.css
files as instructed. - Run the app using
npm start
. - Access the app in your browser at http://localhost:3000.