I have an array that I am passing down to a child component, where I want all the array elements to render in a list. Not complicated, I've done this a bunch of times, except this time I'm not able to get it to format the way I want.
In my parent, I am filtering through an array of objects in my state, and returning the object that I want:
state = {
activeTab: 0,
tabs: [
{
id: 0,
icon: <AiFillShopping />,
label: 'Groceries',
content: ['grocery list', 'test']
},
{
id: 1,
icon: <FaSchool />,
label: 'School',
content: ['school list', 'test']
}
],
value: '',
}
let filteredContent = this.state.tabs.filter((tab, index) => {
if(index === this.state.activeTab) {
return tab;
}
})
console.log(filteredContent) // logs {id: 0, label: "Groceries", content: Array(2)}
Then I'm passing filteredContent to my child, and then in my child I am mapping through the prop to get the content and list the items out as a list:
<ul>
{this.props.content.map(content=> <li>{content.content}</li>)}
</ul>
But it's coming out as one list item, with the elements all in one line like this: "grocery listtest"
I'm sure I just did something stupid, but I've been staring at it for long at this point I could use another pair of eyes.