Here is my code:
......
render() {
var menuItems = [
{name: 'Item 1', subMenus: [{name: 'Sub Menu 1-2'}, {name: 'Sub Menu 1-2'}, {name: 'Sub Menu 1-3'}]},
{name: 'Item 2'},
{name: 'Item 3'},
{name: 'Item 4', subMenus: [{name: 'Sub Menu 4-2'}, {name: 'Sub Menu 4-2'}, {name: 'Sub Menu 4-3'}]},
{name: 'Item 5'}
]
var menu = function () {
return (
menuItems.forEach(function (menuItem, i) {
if (menuItem.subMenus != undefined) {
<ul key={i}>menuItem.name
menuItem.subMenus.forEach(function (subMenu, i) {
<li key={i}>subMenu.name</li>
}
</ul>
} else {
// do nothing
}
})
)
}
return({menu})
......
Obviously it is not working.
What would be the correct procedure to loop thru a nested menu? Thanks in advance.