title: ReactJS: How to use boolean values in radio buttons?
body: <p>What is the proper way to use boolean data in radio buttons. The values will be converted from booleans to strings if used directly.</p>
  
  <p>JSON-data for input fields that is preloaded:</p>
  
  <pre><code>var question = [
    {value: true, name: "Yes"},
    {value: false, name: "Not this time"}
  ]
  </code></pre>
  
  <p>The radio button fields:</p>
  
  <pre><code>&lt;input type="radio" 
         name="question" 
         onChange={this.state.onRadioChange} 
         value={this.state.question[0].value} /&gt; {this.state.question[0].name}
  &lt;input type="radio" 
         name="question" 
         onChange={this.state.onRadioChange} 
         value={this.state.question[1].value} /&gt; {this.state.question[1].name}
  </code></pre>
  
  <p>The binding for onRadioChange:</p>
  
  <pre><code>onRadioChange: function(e) {
      console.log(e.target.value);
  }
  </code></pre>
  
  <p>The console log displays that the selected values are converted from booleans to strings.</p>
  
  <p>One way to handle this would be add an extra function to the <code>onRadioChange</code> function to convert <code>"true"/"false"</code> strings to booleans from <code>e.target.value</code> but its feels a bit hackery. Also, using just 'e.target.checked' won't work, because in some radio button groups I have other values than booleans (that needs to be passed through).</p>
  
  <p>Some universal and clean solution would be to use constant values table that is transformed from and to REST.</p>
  
  <p>Are there any special ReactJS way to do it? Maybe not.</p>