in this example, I have an iterated list of data and i want to apply a class if the index of iteration is even.
so, here is a solution,
data.map((item, index) => {
return (
<p key={index} className={ index%2==0 ? "filled" : "no-filled" }>
{item.name}
</p>
);
})
Top comments (0)