1class Foo extends Component {
2 constructor(props) {
3 super(props);
4 this.handleClick = this.handleClick.bind(this);
5 }
6 handleClick() {
7 console.log('Click happened');
8 }
9 render() {
10 return <button onClick={this.handleClick}>Click Me</button>;
11 }
12}