So i\'ve started with React and ES6 and got stuck with very basics. Really appreciate some help.
handleClick() throws an error:
Uncaught TypeError: C
{menuItems.map(function(item) {
return - {item.text}
;
})}
Because your code is in strict mode (modules are always in strict mode), this
is undefined
inside the function you pass to .map
.
You either have to explicitly set the context by passing a second argument to .map:
{menuItems.map(function(item) {
// ...
}, this)}
Or use an arrow function:
{menuItems.map(
item => - {item.text}
)}