-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
32 lines (27 loc) · 801 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import AddTodo from "./To Do List Project/components/AddTodo";
import TodoItem from "./To Do List Project/components/TodoItem";
import { useState } from "react";
function App() {
const [todo, setTodo] = useState([])
const getItem = (item) =>{
setTodo((prevState)=>{
return {...prevState, item}
})
}
const getCompleted = (id) =>{
setTodo((prevState)=>{
return prevState.filter((item, index)=>{
return index !== id;
})
})
}
return (
<div className="todo">
<AddTodo item={getItem}/>
{todo && todo.map((todo, index)=>(
<TodoItem id={index} item={todo} completed={getCompleted}/>
))}
</div>
);
}
export default App;