I have an object like this:
const arr = {
"items": [{
"id": "61f5530ffa13c013c514cc5f",
"name": "Classic",
"slug": "classics",
"unit": "1 each",
"stock": 200,
"price": 500,
"quantity": 3,
"itemTotal": 1500
}],
"isEmpty": false,
"totalItems": 3,
"totalUniqueItems": 1,
"total": 1500,
"meta": null
};
How can I map the above to an h1 element?
I tried this, I know it's wrong
const myarr = arr.map((item) => {
return <h1 key={item.id}>{item.name}</h1>
});
h1element? What are you expecting to render? It seems like the only problem is you're trying to.mapacross an object, not the array that's one of its values.arr.items. Might be good to not name an objectarrin the first place. Give it a descriptive name.