title: Reactjs: Get value of radio button
body: <p>I'm developing a simple opinion poll as my way of ramping up on reactjs. So far I've come up with the following:</p>
  
  <pre><code>//App.js
  import React, { Component } from 'react';
  import './App.css';
  
  const PollOption = ({options}) =&gt; {
  
  
  return (
      &lt;div className="pollOption"&gt;
        {options.map((choice, index) =&gt; (
          &lt;label key={index}&gt;
          &lt;input type="radio" 
                  name="vote" 
                  value={choice.value} 
                  key={index}
                  defaultChecked={choice.value}
                  onChange={() =&gt; this.props.onChange()}/&gt;
                  {choice.text}
          &lt;/label&gt;
        ))}  
      &lt;/div&gt;
     );
  };
  
  
  
  class OpinionPoll extends Component{
    constructor(props) {
      super(props);
      this.state = {selectedOption: ''}
    }
  
    handleClick(){
      console.log('button clicked');
    }
  
    handleOnChange(){
      console.log('foo');
    }
  
    render(){
      return (
        &lt;div className="poll"&gt;
          {this.props.model.question}
          &lt;PollOption 
            options={this.props.model.choices}
            onChange={() =&gt; this.handleOnChange()}/&gt;
  
          &lt;button onClick={() =&gt; this.handleClick()}&gt;Vote!&lt;/button&gt;
        &lt;/div&gt;
      );
    }
  }
  
  
      export default OpinionPoll;
  
      //index.js
      var json = {
              question: 'Do you support cookies in cakes?',
              choices:
              [
                 {text: "Yes", value: 1},
                 {text: "No", value: 2} 
              ]
          }
      const root = document.getElementById("root");
      render(&lt;OpinionPoll model ={json} /&gt;, root)
  </code></pre>
  
  <p>I want to get the value of the radio button when the button is clicked.</p>