Giter Site home page Giter Site logo

to-do-list-using-react's Introduction

ToDoList React Component

Description

The ToDoList component is a simple React-based to-do list application. It allows users to add tasks, delete tasks, and reorder tasks within the list. The component demonstrates basic state management using React hooks and includes functionality for user interaction through buttons and input fields.

Features

  • Add Task: Users can add a new task to the list by entering text into an input field and clicking the "Add" button.
  • Delete Task: Users can remove a task from the list by clicking the "Delete" button next to the task.
  • Move Task Up: Users can move a task up in the list by clicking the "๐Ÿ‘†" button next to the task.
  • Move Task Down: Users can move a task down in the list by clicking the "๐Ÿ‘‡" button next to the task.

Code Overview

State Variables

  • tasks: An array of tasks (strings) initialized with two default tasks: "eat breakfast" and "take a shower".
  • newTask: A string representing the new task input by the user.

Event Handlers

  • handleInputChange(event): Updates the newTask state with the value entered by the user in the input field.
  • addTask(): Adds the new task to the tasks array if the input is not empty and clears the input field.
  • deleteTask(index): Removes the task at the specified index from the tasks array.
  • moveTaskUp(index): Moves the task at the specified index one position up in the tasks array.
  • moveTaskDown(index): Moves the task at the specified index one position down in the tasks array.

JSX Structure

  • The main component wrapper is a <div> with the class name "to-do-list".
  • The title of the application is displayed in an <h1> tag.
  • An input field for adding new tasks is paired with an "Add" button.
  • The list of tasks is rendered as an ordered list (<ol>), with each task being a list item (<li>) containing:
    • The task text.
    • A "Delete" button to remove the task.
    • An "๐Ÿ‘†" button to move the task up.
    • An "๐Ÿ‘‡" button to move the task down.

How to Use

  1. Add a Task: Type a task into the input field and click the "Add" button. The task will be added to the bottom of the list.
  2. Delete a Task: Click the "Delete" button next to a task to remove it from the list.
  3. Move a Task Up: Click the "๐Ÿ‘†" button next to a task to move it one position up in the list.
  4. Move a Task Down: Click the "๐Ÿ‘‡" button next to a task to move it one position down in the list.
Capture

to-do-list-using-react's People

Contributors

fidaa2002shwahna avatar

Stargazers

Rahaf N As'ad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.