Iterate in an array with objects

const BlogList = ({ list }) => {
  return (
    <div className="blog-list">
      {Object.keys(list).map((keyName, i) => (
    <li className="post" key={i}>
        <p>
          {list[keyName].thumbnail_image}
          </p>
    </li>
))}
    </div>
  );
};

Here I am doing this way but it is giving me errors I don’t where I am doing wrong.The Api data is shown below:
{“posts”:[{
“id” : “HktWbZ1ox”,
“thumbnail_image” : “http://i.imgur.com/HRLcw1j.jpg”,
“event_name” : “Hello1”,
“event_date” : 1506988800,
“views” : 7,
“likes” : 3,
“shares” : 5
},

Are we allowed to know what the error messages are, or is this a riddle?

Can you console.log list so we can see exactly what is being passed in.

I don’t understand this:

      {Object.keys(list).map((keyName, i) => (

and this:

          {list[keyName].thumbnail_image}

The first one implies that list is an object. But the second one implies that the list is the parent of the object that holds “thumbnail_image” - but that would be an array.

I think you have some confusion over what your data is.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.