5.
What value of button will allow you to pass the name of the person to be hugged?
import React from 'react';
class HugSender extends React.Component {
sendHug(personName) {
console.log("Sending a hug to " + personName);
}
render() {
let receiverName = "friend";
let button = (
// Missing Code
);
return button;
}
}
export default HugSender;
<button onClick={() => this.sendHug({receiverName})}>Hug Me</button>
<button onClick={this.sendHug(receiverName)}>Hug Me</button>
<button onClick={() => this.sendHug(receiverName)}>Hug Me</button>
<button onClick={() => sendHug(receiverName)}>Hug Me</button>
Correct: C
To pass the receiverName of the person to be hugged, you can use the arrow function with the onClick event. You can include the receiverName as an argument in the function call. For example, onClick={() => this.sendHug(receiverName)} will pass the value of receiverName to the sendHug function when the button is clicked.