I am trying to iterate/map through an array of objects and use nested values, but I cannot seem to get it to work. If i pass in a simple array
const people = [
{ name: "joe", id: "1" },
{ name: "mary", id: "2" }
];
to my ShowList component
const ShowList = (props) => {
const {people} = props;
return ( renderPeep(people))
};
const renderPeep = (people) => (
<ul>
{people.map((peep, index) => (
<li key={index}>{peep}</li>
))}
</ul>
)
I get a list of both values:
joe1
mary1
and both dot notation and bracket dont work ({peep.name} ) to just list names. is the map function causing us to lose keys info on the underlying objects? what am I missing?
peep.nameorpeep.id.peep.get('name')that I needed.