-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
33 lines (31 loc) · 795 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
class App extends React.Component {
state = {
items: [
{ id: 1, name: "te", active: false },
{ id: 2, name: "kafe", active: false },
{ id: 3, name: "semola", active: false },
{ id: 4, name: "sopa", active: false },
{ id: 5, name: "agua hirviendo", active: false },
{ id: 6, name: "pan", active: false },
],
}
handleChangeStatus = (id) => {
const items = this.state.items.map(item => {
if (id === item.id) {
item.active = !item.active
}
return item
})
this.setState({
items
})
}
render() {
return (
<React.Fragment>
<Header items={this.state.items} />
<ListItems items={this.state.items} changeStatus={this.handleChangeStatus} />
</React.Fragment>
)
}
}