I have a json file that looks similar to this:
[
{
"January": [
{
"Date": "Jan 1st",
"Event": "New Years"
},
{
"Date": "Jan 17th",
"Event": "Chinese New Year"
}
],
"February": [
{
"Date": "Feb 14th",
"Event": "Valentine's Day"
},
{
"Date": "Feb 29th",
"Event": "Leap Year"
}
]
}
]
The json file is structured like this but has many more events and months.
I've tried using a nested loop, and nothing is being returned in JSX. I'm able to get results if I console log it, so I'm not sure if maybe I'm using the wrong functions and if I should use two map loops instead of a forEach with a map loop inside. Here's what I've tried so far:
{EventsList.forEach((monthObj) => {
const monthObjKeys = Object.keys(monthObj);
monthObjKeys.map((monthKey) => {
const monthArr = monthObj[monthKey];
return (
<div className='Events__ItemList'>
<h1 className='Events__Month'>{monthObjKeys}</h1>
<div className='Events__Item'>
<p className='Events__Date'>{monthArr.Date}</p>
<p className='Events__Name'>{monthArr.Name}</p>
</div>
</div>
);
});
})}
Any help/suggestions would be much appreciated