I made a todo app and I wanted to improvise it by showing all completed task if "Show completed task" is checked
Checking "Show completed task" works fine, but unchecking it doesn't execute the "else statement".
Originally what wanted is if its unchecked it should give me all the state, completed or not.
The code from 'else statement' is just for debugging. It should at least give me the array[0] and array[2], tried console logging it, and it throws an undefined.
PS: tried to console log something upon unchecking, unchecked is working.
filterCompleted = (e) => {
if(e.target.checked){
this.setState({todos: [...this.state.todos.filter(todo => {return todo.completed === true})]})
}
else{
//code below just for debugging but this does not execute
this.setState({todos: [...this.state.todos.filter(todo => {return todo.completed === false})]})
}
}
Aucun commentaire:
Enregistrer un commentaire