How to pass the value of the active radio buttons in array for display?

Hi all! I'm new to React and are working on creating a simple Quiz widget, but encountered a problem: to add to the array of answers result, which is stored in the selected radio button. Write on ReactJS. Thanks in advance for your help. Code example:

class Results extends React.Component { 
 constructor(props) { 
super(props);
 this.state = {
 isStarting: false
}
}


 checkRes = () => {
this.setState({
 isStarting: true
})
}
 render = () => {
 const { isStarting } = this.state;
});

 if (!isStarting) { 
 return (
the <div>
 <h1>voting Results:</h1>
 <p>.........</p> // Answers massive
 <button type="submit" onClick={this.checkRes}>Start over</button>
</div>
);
}
 return <Question1 /> 
}
}




class Question1 extends React.Component {
 constructor (props) {
super(props);
 this.state = {
 isStarting: false,
 option: 'Select an answer' // Next time change this parameter
}
}

 ansQ1 = () => { 
this.setState({
 isStarting: true
})
}


 handleRadioChange(event) {
 this.setState({option: event.target.value});
}


 render = () => {

 const { isStarting } = this.state;
 if (!isStarting) {
 return (
 the <div> 
 <p>What ice cream do you prefer?</p>
 <p>Your choice: {this.state.option}</p>

<input
name="var1"
type="radio"
value="Sundae"
 checked={this.state.option == 'ice Cream'}
onChange={this.handleRadioChange.bind(this)}
 /><span>ice Cream</span><br />

<input
name="var2"
type="radio"
value="Chocolate"
 checked={this.state.option == 'Chocolate'}
onChange={this.handleRadioChange.bind(this)}
 /><span>Chocolate</span><br />

<input
name="var3"
type="radio"
value="Pistachio"
 checked={this.state.option == 'Pistachio'}
onChange={this.handleRadioChange.bind(this)}
 /><span>Pistachio</span><br />

 <button type="submit" onClick={this.ansQ1}>Next</button>
</div>
);
}
 return <Results />
}

class App extends React.Component {
 render () {
 return (
 <Question1 />
);
}
}
export default App;
April 3rd 20 at 17:16
1 answer
April 3rd 20 at 17:18

Find more questions by tags ArraysReact