What is the correct way to bind this to the handleClick method inside the constructor?
class App extends React.Component {
constructor() {
super();
// Complete the binding statement here
}
handleClick() {
console.log("Button clicked!");
}
render() {
return <button onClick={this.handleClick}>Click Me</button>;
}
}
this.handleClick = handleClick.bind(this)
this.handleClick = this.handleClick()
this.handleClick = this.handleClick.bind(this)
this.handleClick = handleClick
This question is part of this quiz :
Event Handling in React