I have this object in its parent components and am passing it down to the child component then mapping over it then after I have mapped I try to use otherPokemon.base.[key] and this gives me an error right after the period. Here is the object:
{
pokemon1: {
name: "Pikachu",
image: "https://raw.githubusercontent.com/Purukitto/pokemon-data.json/master/images/pokedex/thumbnails/025.png",
description: "While sleeping, it generates electricity in the sacs in its cheeks. If it\u2019s not getting enough sleep, it will be able to use only weak electricity.",
base: {
"HP": 35,
"Attack": 55,
"Defense": 40,
"SpAttack": 50,
"SpDefense": 50,
"Speed": 90,
},
},
pokemon2: {
name: "Squirtle",
image: "https://raw.githubusercontent.com/Purukitto/pokemon-data.json/master/images/pokedex/thumbnails/007.png",
description: "Squirtle\u2019s shell is not merely used for protection. The shell\u2019s rounded shape and the grooves on its surface help minimize resistance in water, enabling this Pok\u00e9mon to swim at high speeds.",
base: {
"HP": 44,
"Attack": 48,
"Defense": 65,
"SpAttack": 50,
"SpDefense": 64,
"Speed": 43
},
}
}
then in the child component:
<List component="div" disablePadding>
{Object.entries(pokemon.base).map(([key, value]) => {
console.log(otherPokemon.base.[key])
return(
<ListItem>
<ListItemText>{key + ": "}<span className={value > otherPokemon.base.[key] ? classes.more : classes.less}>{value}</span></ListItemText>
</ListItem>)
})}
</List>
the code actually works but the file becomes red and the error bit gets a red underline saying:
Any help would be appreciated :)