I have several dynamically generated material UI buttons, and when user clicks any of them I would like to know which was clicked (let's say obtain the value of name attribute which I assigned below). How can this be solved? Basically I want to retrieve some attribute of the button which was clicked. Here is some code
{ that.state.items.map(function (item) { return ( <div key={item.id}> <FlatButton label={item.regionName} name={item.id} primary={true} onClick={that.handleRegionClick} ></FlatButton> </div> ); }); } handleRegionClick(e); { console.log(e.target.name); // This prints undefined // If I could get here the _item.id_ which I assigned to _name_ I would be fine. } PS. I also have this in constructor
this.handleRegionClick = this.handleRegionClick.bind(this);