I have a reaction function that returns a list of each item in an array after displaying. Within the maps function, i want to check and see if certain parameters are met and render different divs depending on those if statements. When I add a return() that wraps around each of items in the array, I get an error with the if statement. If I do not add the return() it will not render anyrhing. I want to render each item in the array in a way that doesnt show an error with the if statements. here is my code below:
export default function Details(props){
return(
<div>
<p>Homiez</p>
{
props.details.map((detail) => {
if(detail.owes === 'Omar'){
<div>
<span>You owe {detail.owed} ${detail.amount} for {detail.description}</span>
</div>
}
else if(detail.owed === 'Omar'){
<div>
<span>{detail.owes} owes You ${detail.amount} for {detail.description}</span>
</div>
}
else {
<div>
<span>{detail.owes} owes {detail.owed} %{detail.amount} for {detail.description}</span>
</div>
}
})
}
</div>
)
}