I have an array of data that is returned to me from a CMS. I map over each item and return a component with the corresponding data. However, I need to target the last item in the .map
function in the render
method as the last item needs some modification.
How would I do this?
return (
<div>
{data.body.map((item, i) => {
console.log(i);
if (item.type === 'button') {
return <ButtonComponent color="ffffff" bgColor="4C319D" text={item.text} textAlign="left" id={item.id} />
}
})}
</div>
)