Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand All @@ -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);
};
Expand All @@ -22,6 +28,15 @@ function App() {
<button onClick={handleAddTask}>추가</button>
<div>
{tasks.map((task, index) => (
<div key={index}>
{task}
<div onClick={() => handleDelete(index)}> 삭제 </div>
</div>
))}
</div>
<div>##################################</div>
<div>
{doneTasks.map((task, index) => (
<div key={index}>{task}</div>
))}
</div>
Expand Down