I've been trying to map over the product object below coming from state to display divs with their corresponding size in React.
{
name: 'Aphelandra',
image: './prod-img/aphelandra.jpeg',
description: 'Lorem ipsum dolor sit amet consectetur, adipisicing elit.',
size:
[
{
title: 'sm',
price: 31,
countInStock: 111,
},
{
title: 'md',
price: 56,
countInStock: 24,
},
{
title: 'lg',
price: 88,
countInStock: 13,
}
],
},
{
I have been trying unsuccesfully to do this with different variations of this function:
<div>
{product.size.map(title => (
<div>{title}</div>
))}
</div>
Other properties display fine like this:
<p>{product.description}</p>
But I cant find a way to get size. Most common error is cannot read property 'map' of undefined
How can I get through this array?