React | Event Handling | Question 5

Last Updated :
Discuss
Comments

In the code snippet below, how can you pass an argument to the handleClick function?

JavaScript
function MyButton() {
    const handleClick = (name) => {
        alert(name);
    };
    return <button onClick={handleClick}>Click Me</button>;
}


onClick={handleClick('John')}

onClick={() => handleClick('John')}

onClick={handleClick, 'John'}

onClick={handleClick}

Share your thoughts in the comments