// with return with a single child
{events.map((item) => {
return <p>{item.title}</p>;
}
)}
// with return with a multiple children
{events.map((item) => {
return (
<>
<p>{item.title}</p>
<p>{item.description}</p>
</>
);
}
)}
// with return and conditional
{events.map((item, index) => {
if (index % 2 === 0) {
return (
<p>{index}{item.title}</p>
);
}
})}
//no return declaration and single child
{events.map((item, index) => (
<p>{item.title}</p>
)
)}
//no return declaration and multiple chidlren
{events.map((item, index) => (
<>
<p>{item.title}</p>
<p>{item.description}</p>
</>
)
)}
//Ps.: conditionals are only allowed with return declaration