-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
47 lines (42 loc) · 831 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, { Component } from 'react';
import './App.css';
import Todos from "./components/Todos";
class App extends Component {
state = {
todos: [{
id:1,
title: "take out the trash",
completed: false
},
{
id:2,
title: "dinner with wife",
completed: false
},
{
id:3,
title: "meeting with boss",
completed: false
}
]
}
//toggle complete
markComplete=(id)=>{
this.setState({todos:this.state.todos.map(todo =>{
if(todo.id === id){
todo.completed = !todo.completed
}
return todo;
}
)});
}
render() {
// console.log(this.state.todos)
return (
<div className="App">
<Todos todos={this.state.todos} markComplete={this.markComplete}/>
</div>
);
}
}
export default App;