REACT: Map over nested array of objects

前端 未结 2 954
无人及你
无人及你 2020-12-09 23:09

I am trying to map over array of objects which each array contains another nested array of objects. However, the map does not work on the nested array. How do i map over the

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 00:06

    Since each element has a content array, you must map over content as well.

    Example

    {dataItems.map((item, index) => (
      

    {item.title}

    {item.content.map((c, i) => (

    {c.title}

    {c.description}


    ))}
    ))}

提交回复
热议问题