I'm having trouble wrapping my head around the rendering of nested objects and arrays. How can I loop through my objects and render this data?
I'm calling an API. Here's the hook and the JSX.
const [orderData, setOrderData] = useState([]);
return (
<>
<div>
<ul>
{orderData.map(item => {
console.log(item);
})}
</ul>
</div>
</>
);
console.log(item)
returns six objects.
Here are the six objects.
First item is an object with an array of objects. The other five objects contain objects.
How can I render data from all six objects within the JSX? I want to be able to access data from each object. How can I loop through these?
As for UI: it doesn't really matter. For now, I just want to access all of the data and render it in a UL or something.
Accessing data.orders
.
Attempting to access data.orders.deadline
, or data.orders.description