As you can see from the code, at first I want all the todos to be shown, then toggle between all, active and completed todos. I have made the arrays for the active and completed todos, but I’m not quite sure how to implement the switching between those lists. For example, how can I render only active todos instead of the all the todos, etc.?
return (
<div className='card'>
<TodoForm addTodo={addTodo} />
<div className='list-group'>
{
todos.map((item, index) =>
item.isEditing ? <TodoEditForm item={item} key={index} editTask={editTask} /> :
<Todo item={item} key={index}
toggleCompleted={toggleCompleted}
removeTodo={removeTodo}
toggleEdit={toggleEdit} />
)
}
{
bool ?
<div>
Active
</div>
:
<div>
Completed
</div>
}
</div>
<div className='toggle-todos-wrapper'>
<button className="toggle-todos-button btn btn-light">All</button>
<button className="toggle-todos-button btn btn-light">Active</button>
<button className="toggle-todos-button btn btn-light">Completed</button>
</div>
</div>
)
}
export default TodoWrapper
I tried using the ternary operator to switch between the active and completed todos, but the all todos remain.
