Hello i want to nest a list component inside a list component. The first list is an option group list, each of its items has a list of options. I think the problem comes from the nested IndicatorRow. I could'nt find a same example around.
var IndicatorRow = React.createClass({
render: function() {
var indicators = [];
for (var key in this.props.indicatorsOfGroup) {
indicators.push( <option value={key} > {this.props.indicatorsOfGroup[key]}</option> );
}
return {indicators} ;
}
});
var IndicatorGroup = React.createClass({
render : function(){
var indicatorsGroup = [];
for (var key in this.props.indicatorsGroups) {
var indicatorsOfGroup = this.props.indicatorsGroups[key].indicators;
indicatorsGroup.push(
<optgroup label={key}>
<IndicatorRow indicatorsOfGroup={indicatorsOfGroup}/>
</optgroup> );
}
return ( <select>
{indicatorsGroup}
</select> );
}
});
ReactDOM.render(
<form>
<fieldset className="form-group">
<IndicatorGroup indicatorsGroups={indicatorsSelected}/>
</fieldset>
</form>
,
document.getElementById('indicators')
);
My data is structured as below
var indicatorsSelected = {
"Economy & Growth": {
"indicators": {
"id1": "Indicator 1",
"id2": "Indicator 2"
}
},
"Energy & Mining": {
"indicators": {
"id1": "Indicator 1",
"id1": "Indicator 2"
}
},
"Environment": {
"indicators": {
"id1": "Indicator 1",
"id2": "Indicator 2"
}
},
{...}
};
I would appreciate any help