Objects are not valid as a React child (). If you meant to render a collection of children, use an array
I receive the above error and I don't fully understand the limitations of what it's telling me. Here is my code that is giving me this error, I have an object where one of the properties has the value of an array of objects:
state = {
clubs: [{
teamName: something,
gamesPlayed: [{
homeTeam: someName,
awayTeam: someNameElse,
score: numbers
},
{
homeTeam: ...
... etc
}]
}]
}
The element that renders the code:
function RenderTest(props) {
return (
<ul>
<li>
<div>
<ul style={{paddingLeft: 10+'px'}}>
{props.clubs.map( (key, i) => (
<li>
<div>Team: {key.teamName} ID: {key.teamId}</div> <-- works as expected
<div>Games Played: {key.gamesPlayed.home}</div> <-- throws the error
</li>
))}
</ul>
</div>
</li>
</ul>
)
}
Does it mean that I cannot have a nested object like this? It seems a bit limiting. It seems logical that I store the data like this - clubs is an array of objects, each one a football team with their games played that season.
Thank you
key.gamesPlayed[i].scorean object ?key.gamesPlayed[i].scoreis an objectmap?