[SOLVED] REACT function call from onClick event

I haven’t figured out how to do this to any level of success yet.

Any reason why this function sendVote() never gets fired at the onClick event?
class RadioRows extends Component {

    constructor(props) {

        super(props);
        this.state = {
            currentVoteResponse: '',
            currentPollId: this.props.pollId
        }
    }   

    sendVote(){  
        console.log("You selected: this.props.resp=" +  this.props.resp);
        var resp = this.props.resp;

    }

    render(){

            return (
            <div className="responseBox">

                <label><input key={this.props.key} name="megha" 
                        onClick={this.sendVote.bind(this)}
                        type="radio" 
                        placeholder="bawa" 
                        value={this.props.resp}  />
                            &emsp;{this.props.resp}
                        </label>&emsp;
                current score: {this.props.votes}
            </div>
            );

    }

}


RadioRows.propTypes = {
  resp: PropTypes.string.isRequired,
  votes: PropTypes.number.isRequired,
  sendVote: PropTypes.func.isRequired
};

I copy/pasted your code and it works for me.

Btw, you are missing React here:

RadioRows.propTypes = {
  // should be React.PropTypes....
  resp: PropTypes.string.isRequired, 
  votes: PropTypes.number.isRequired,
  sendVote: PropTypes.func.isRequired
};

Yes code seems to work now thanks. Just other issues appearing elsewhere now :confused:

I am importing React so I don’t need to preface resp: PropTypes.string.isRequired, with React.

I know this because I get the warning:

Failed prop type: The prop `sendVote` is marked as required in `RadioRows`, but its value is `undefined`.