//todo
https://stackoverflow.com/questions/36651583/dynamically-add-child-components-in-react
var App = React.createClass({
getInitialState: function(){
return [
{id:1,name:"Some Name"}
]
},
addChild: function() {
// State change will cause component re-render
this.setState(this.state.concat([
{id:2,name:"Another Name"}
]))
}
render: function() {
return (
<div>
<h1>App main component! </h1>
<button onClick={this.addChild}>Add component</button>
{
this.state.map((item) => (
<SampleComponent key={item.id} name={item.name}/>
))
}
</div>
);
}
});
<Component {...this.props} more="values" />
https://gist.github.com/xgqfrms-gildata/c547bf26178fbc7b35d7f8458eed4fbd
https://jsfiddle.net/reactjs/69z2wepo/
https://codepen.io/gaearon/pen/KgQKPr?editors=0010
https://codepen.io/bradleyboy/pen/OPBpGw
https://github.com/bradleyboy/codepen-react