React.createElement
takes a spread \"children\" parameter
var d = React.DOM;
React.createElement(LabeledElement, {label: \"Foo\"},
d.input({v
The children passed to a component, either via JSX nesting or via the third+ argument to React.createElement
, shows up in the component as this.props.children
:
var MyLabel = React.createClass({
render: function() {
return React.createElement("label", {className: "label"},
React.createElement("span", {className: "label"}, this.props.label),
this.props.children
);
}
});
var App = React.createClass({
render: function() {
return React.createElement(MyLabel, {label: "Here is the label prop"},
React.createElement("div", {},
React.createElement("input", {type: "text", value: "And here is a child"})
)
);
}
});
Example: http://jsfiddle.net/BinaryMuse/typ1f2mf/; docs: http://facebook.github.io/react/docs/multiple-components.html#children