1class Button extends React.Component {
2
3 handleId = (e) => {
4 /*Well if the elements are nested event.target won't always work
5 since it refers to the target that triggers the event in the first place.*/
6 console.log(e.target.id);
7 console.log(e.currentTarget.id);
8 }
9
10 render() {
11 return (
12 <button id="yourID" onClick={this.handleId}>Button</button>
13 );
14 }
15}
16