//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" />
react-nanodegree
https://cn.udacity.com/course/react-nanodegree--nd019/
https://s3.cn-north-1.amazonaws.com.cn/static-documents/nd019/ReactNDsyllabusZH.pdf