i have a function
const [tasks, setTasks] = useState([])
const addTask = (title, role) => {
const newTasks = [...tasks, { title, role}]
setTasks(newTasks)
}
every form is submitted, addTask function is create state data containing an array of objects
[
{title: "make a coffee", role: "employee"},
{title: "react the sales target", role: "salesman"},
{title: "clean the room", role: "employee"},
{title: "call the client", role: "boss"},
]
i want to populate task based on role
const TaskList = ({ tasks }) => {
return (
<Container>
<Row>
{tasks.map((task, index) =>
<Col sm="12" md="4">
<h4 style={{ textAlign: 'center' }}>
{task.role}
</h4>
<TaskCard task={task} index={index} />
</Col>
)}
</Row>
</Container>
)
}
const TaskCard = ({ task, index, completeTask, editTask, removeTask }) => {
return (
<Container className="mb-3">
<Card body inverse color={task.completed ? 'success' : 'danger'}>
<CardText>{task.title}</CardText>
<p></p>
<div className="Card-btn">
<i className="fas fa-check-circle fa-2x fa-fw" onClick={() => completeTask(index)}></i>
<i className="fas fa-pen fa-2x fa-fw" onClick={() => editTask(index)}></i>
<i className="fas fa-trash-alt fa-2x fa-fw" onClick={() => removeTask(index)}></i>
</div>
</Card>
</Container>
)
}
but instead of create a task list column for each role, its create new role card

how to populate task in column based by role? should i filter it first?
<TaskCard task={task} index={index} />is inside themap()