I am trying to render a series of buttons from an array of objects.
const numbers =
[{
key:"C",
id:"clear"
},{
key:"/",
id:"divide"
},
{
key:"*",
id:"multiply"
}]
I tried to use regular function. It renders the buttons, but it wouldn't trigger the click action.
{numbers.map( function(item) {
return (<button class="button btn btn-light" id={item.id} onClick={this.handleClick}>{item.key}</button>);
}
The following works
{numbers.map( item=>
<button class="button btn btn-light" id={item.id} onClick={this.handleClick}>{item.key}</button>)
}
What do I need to change in regular function to make it behave like arrow function?