-2
When I try to access the property this.props.arrayMenu shows me the following error:
Uncaught Typeerror: Cannot read Property 'id' of Undefined.
import React , { Component } from 'react';
export default class Categorais extends Component
{
render(){
return(
<div className="row">
{
this.props.arrayMenu.map(function(menuItem, i) {
if (menuItem.submenu !== undefined) {
return (
<ul key={i}>{menuItem.categoria}
{menuItem.submenu.map(function(subMenu, i) {
return <li key={i}>{subMenu.categoria}</li>;
})}
</ul>
)
}
else
{
return (
<ul key={i}>
<li key={i}>{menuItem.menu.categoria}</li>
</ul>
)
}
})
}
</div>
);
}
}
There is no way to know if the "category" of
menuItem
of histhis.props.arrayMenu
are Undefined or not. You should check the content of your props. We have no way to guess what you develop and does not show.– Ericson Willians