//Well if the elements are nested event.target won't
//always work since it refers to the target that triggers the
//event in the first place. See this link for the usage of event.currentTarget,
//which always refer to the element that the handler is bound to.
class Button extends React.Component {
getButtonId = (e) => {
console.log(e.currentTarget.id);
}
render() {
return (
<button id="yourID" onClick={this.getButtonId}>Button</button>
);
}
}