Closed stephmilovic closed 8 years ago
Hello. I am trying to iterate through an array to get the values for the Radio components. However, I'm having issues:
renderRadios(options){ let radioItems = []; for (let i = 0; i < options.length; i++) { const option = options[i]; radioItems.push( <Radio value={option.value} label={option.label} /> ) } return radioItems; } render() { return ( <div> <h1>&x-{this.props.parameterData.param}={this.props.parameterData.default}</h1> <RadioGroup name={this.props.parameterData.param} selectedValue={this.state.selectedValue} onChange={this.handleChange}> {Radio => ( <div> {Object.keys(this.props.options).map(this.renderRadios)} </div> )} </RadioGroup> </div> ); }
Since Radio is not defined, I am getting an error. If I put the loop right in the Radio => function, I get syntax errors. How can I accomplish this?
Radio =>
I've made a JSFiddle here.
What is the solution here ?
Hello. I am trying to iterate through an array to get the values for the Radio components. However, I'm having issues:
Since Radio is not defined, I am getting an error. If I put the loop right in the
Radio =>
function, I get syntax errors. How can I accomplish this?I've made a JSFiddle here.