title: how can i change class based radio button group to functional based radio group
body: <p>this is the class based radio group . I want to convert it to functional based radio group. how can i do it. the code is as below:</p>
  <pre><code>import React, { Component } from &quot;react&quot;;
  
  class Demo2 extends Component {
    constructor() {
      super();
      this.state = {
        name: &quot;React&quot;
      };
      this.onValueChange = this.onValueChange.bind(this);
      this.formSubmit = this.formSubmit.bind(this);
    }
  
    onValueChange(event) {
      this.setState({
        selectedOption: event.target.value
      });
    }
  
    formSubmit(event) {
      event.preventDefault();
      console.log(this.state.selectedOption)
    }
  
    render() {
      return (
        &lt;form onSubmit={this.formSubmit}&gt;
          &lt;div className=&quot;radio&quot;&gt;
            &lt;label&gt;
              &lt;input
                type=&quot;radio&quot;
                value=&quot;Male&quot;
                checked={this.state.selectedOption === &quot;Male&quot;}
                onChange={this.onValueChange}
              /&gt;
              Male
            &lt;/label&gt;
          &lt;/div&gt;
          &lt;div className=&quot;radio&quot;&gt;
            &lt;label&gt;
              &lt;input
                type=&quot;radio&quot;
                value=&quot;Female&quot;
                checked={this.state.selectedOption === &quot;Female&quot;}
                onChange={this.onValueChange}
              /&gt;
              Female
            &lt;/label&gt;
          &lt;/div&gt;
  </code></pre>
  <p>i want it working code for functional based component. i am new to react pls help.</p>