React

ReactJS Practical Questions - class extends react

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>