I have created a todo app and I am trying to filter todos in 3 different conditions all, completed, incompleted. As default I want to show all the items and then filter them. I know that I can use filter as follow for example:
array.filter(t => t.completed) or array.filter(t => !t.completed)
but I dont know how to render all of them and then render the filtered items only. The code is as follow:
render() {
let notes = this.state.notes.filter(n => n.completed).map((todo,
index) => {
return (
<Todo
key={index}
note={todo}
deleteTodo={() => this.deleteTodo(index)}
handleClick={() => this.handleClick(index)}/>
);
});
const allNotes = this.state.notes.length
let completedNotes = this.state.notes.filter(n => n.completed).length
let incompletedNotes = this.state.notes.filter(n =>
!n.completed).length
return (<div>{notes}</div>);