I'd like to create a flexible/dynamic JSX form format that can be rendered using React.js. This format has to include nested groups. A group can contain other groups as well as questions.
var Group = React.createClass({
render: function(){
return (
<fieldset></fieldset>
);
}
});
var Text = React.createClass({
render: function() {
return (
<label>
<input type="text"/>
</label>
);
}
});
React.render(
<form>
<Group>
<Text/>
</Group>
<Text/>
</form>,
document.getElementById('container')
);
I want to produce:
<form>
<fieldset>
<label>
<input type="text">
</label>
</fieldset>
<label>
<input type="text">
</label>
</form>
However the <fieldset> element is not populated. The output just contains an empty <fieldset>.
How should I nest react.js components, and still maintain the flexibility of re-using question and group components at root and nested levels?