diff --git a/src/App.js b/src/App.js index b428f9a..3570f7f 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,8 @@ import React, { useState } from "react"; function App() { - const [tasks, setTasks] = useState([]); + const [tasks, setTasks] = useState(["자기", "놀기", "먹기"]); + const [doneTasks, setDoneTasks] = useState([]); const [input, setInput] = useState(""); const handleAddTask = () => { @@ -11,6 +12,11 @@ function App() { } }; + const handleDelete = (index) => { + const newTasks = tasks.filter((task, i) => i != index); + setTasks(newTasks); + }; + const handleChange = (event) => { setInput(event.target.value); }; @@ -22,6 +28,15 @@ function App() {
{tasks.map((task, index) => ( +
+ {task} +
handleDelete(index)}> 삭제
+
+ ))} +
+
##################################
+
+ {doneTasks.map((task, index) => (
{task}
))}