Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140788

Map inside a map to get subarray

$
0
0

I have the following data:

{
"data": {
"site": {
  "siteMetadata": {
    "siteLinks": [
      {
        "title": "title 1",
        "submenu": [
          {
            "title": "test-1",
          }
        ]
      },
      {
        "title": "title 2",
        "submenu": [
          {
            "title": "test-2",
          }
        ]
      },
      {
        "title": "title-3",
        "submenu": [
          {
            "title": "test-3",
          }
        ]
      },
      {
        "title": "title-4",
        "submenu": [
          {
            "title": "test-4",
          }
        ]
      }
    ]
  }
}

} }

and I am trying to map to get the submenu title. I have managed to get the first title working with the following code but I am struggling to get the map inside a map.

import React from "react"

const Header = props => (
<div>
    {props.siteLinks.map((item, key) => (
        <div>
            <li key={item.title}>{item.title}</li>
        </div>
    ))}
</div>
)

export default Header

Any help would be much appreciated


Viewing all articles
Browse latest Browse all 140788

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>