With any other language this is an absolute doddle but with REACT this is a nightmare.
class RadioRows extends Component {`
constructor(props) {
super(props);
this.state = {
currentVoteResponse: '',
currentPollId: this.props.pollId
}
}
sendVote(id, res){
// res needs setting
console.log('You selected: ID ='+ id + ' RESP=' + res + ' this.props.resp=' + this.props.resp);
var resp = this.props.resp;
/* Api.put('/api/polls/' + resp, null, (err, response) => {
if (err) {
alert("Error: " + err);
return;
}
*/
// console.log("after submitting vote",response)
//});
}
render(){
let handleSelector = function handleSelect(e,f) {
//e.preventDefault();
// TODO not sure how to set state from here:
alert(e + 'You selected: ' + f);
this.sendVote(e, f)
//this.setState({radiovalue:e.target.value});
console.log("previous radio value",this.state.bind(this))
console.log("new radio value",e.target.value)
}
return (
<div className="responseBox">
<label><input key={this.props.key} name="megha"
onClick={() => this.sendVote(this.props.pollId, this.props.resp)}
type="radio"
placeholder="bawa"
value={this.props.resp} />
 {this.props.resp}
</label> 
current score: {this.props.votes}
</div>
);
}
// () => this.sendVote(this.props.pollId, this.props.resp)
// <div className="boldText width25pct"> {this.props.resp} </div>
// <button key={this.props.key} onClick={this.vote.bind(this)}>Vote</button> (not needed)
}
RadioRows.propTypes = {
resp: PropTypes.string.isRequired,
votes: PropTypes.number.isRequired,
sendVote: PropTypes.func.isRequired
};
I can’t pass the selected value back to the parent.
Any ideas??
I used this idea: http://stackoverflow.com/questions/29694078/how-do-i-use-radio-buttons-in-react