From 9bad5284950dca2a1090984a29a224456ffea732 Mon Sep 17 00:00:00 2001 From: AKASH YADAV Date: Sat, 31 Jan 2026 00:36:43 +0530 Subject: [PATCH] Implement editing feature for Todo items Added editing functionality to Todo items. --- TODO-LIST/src/components/Todo.jsx | 40 +++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/TODO-LIST/src/components/Todo.jsx b/TODO-LIST/src/components/Todo.jsx index a1bee9e..cbba2e2 100644 --- a/TODO-LIST/src/components/Todo.jsx +++ b/TODO-LIST/src/components/Todo.jsx @@ -1,14 +1,46 @@ -import React from 'react' +import React, { useState } from 'react' + + +const Todo = ({ todo, deleteTodo, moveUp, moveDown, total, index }) => { + + const [isEditing, setIsEditing] = useState(false); + const [editText, setEditText] = useState(todo.text); -const Todo = ({ todo,deleteTodo,moveUp,moveDown,total,index}) => { return (
-

{todo.text}

+ {isEditing ? ( + setEditText(e.target.value)} + /> +) : ( +

{todo.text}

+)} +
moveUp(todo.id)}>
moveDown(todo.id)}>
-
deleteTodo(todo.id)}>
+
deleteTodo(todo.id)}>
+ +
setIsEditing(true)} +> +
+ +{isEditing && ( + +)} +
)