React | Event Handling | Question 7

Last Updated :
Discuss
Comments

What is the correct way to bind this to the handleClick method inside the constructor?

JavaScript
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

Share your thoughts in the comments