Problem
I don't understand how to check all the boxes, Before ask something i saw different posts:
so far i tried to implement a little function but it doesn't work
this is my first part of my class App
class App extends React.Component{
constructor(props) {
super(props)
this.state = {
todoValue: "",
filterType: "All",
todos: [],
}
}
checkAll = () => {
this.setState((prevState) => {
return {
todos: prevState.todos.map((item, i) => {
return {
...item,
done: !prevState.todos[i].done,
}
})
}
})
}
this is the render method
render() {
return (
<div className="container">
<Header countTodo={this.state.todos.length}/>
<Form handleDelete={this.handleDelete}
handleToggle={this.handleToggle}
handleClick={this.handleClick}
handleChange={this.handleChange}
todoValue={this.state.todoValue}
todos={this.getVisibleTodos()}/>
<input type="checkbox" onClick={this.checkAll}></input>
<Footer setActiveFilter={this.setActiveFilter}
deleteCompleted={this.deleteCompleted}
filter={this.state.filterType && "New"}/>
</div>
)
}
}
Aucun commentaire:
Enregistrer un commentaire