You reimplement the existing method React.createElement.
You can simply save the unique details for your components in an array, and then create a list of components using these details.
var propsList = [
{ id: 1, d: 'path', fill: 'none' },
{ id: 2, d: 'path', fill: 'none' },
{ id: 3, d: 'path', fill: 'none' }
];
var components = propsList.map(function(props) {
return React.createElement('g', props);
});
var App = React.createClass({
render: function() {
return React.createElement('div', null, components);
}
});
ReactDOM.render(
React.createElement(App, null),
document.getElementById('content')
);
, , .
var App = React.createClass({
getInitialState: function() {
return {
propsList: []
};
},
addProps: function(props) {
var propsList = this.state.propsList.concat([props]);
this.setState({ propsList: propsList });
},
render: function() {
var components = this.state.propsList.map(function(props) {
return React.createElement('g', props);
});
return React.createElement('div', null, components);
}
});