ReactJS map through Object

前端 未结 8 2119
别跟我提以往
别跟我提以往 2021-01-31 16:53

I have a response like this:

I want to display the name of each object inside this HTML:

{subjects.map((item, i) => (
  
  • 8条回答
    •  情歌与酒
      2021-01-31 17:09

      I am not sure why Aleksey Potapov marked the answer for deletion but it did solve my problem. Using Object.keys(subjects).map gave me an array of strings containing the name of each object, while Object.entries(subjects).map gave me an array with all data inside witch it's what I wanted being able to do this:

      const dataInfected = Object.entries(dataDay).map((day, i) => {
          console.log(day[1].confirmed);
      });
      

      I hope it helps the owner of the post or someone else passing by.

    提交回复
    热议问题