var List = React.createClass({
render: function() {}
});
当用React.createClass创建List类的时候,回调函数只有一个getDefaultProps 会被调用,返回一个对象,这个对象会以引用的方式被所有的实例共享。
组件不允许修改自己的props,只能通过父组件来修改。这是为了保持props的一致性。
List类创建完成之后,就可以进行实例化。
1.getInitialState 获取this.state默认值
2.componentWillMount 在render之前调用此方法,处理在render之前需要do 的things
3.render 渲染并返回一个虚拟DOM
4.componentDidMount 在render之后调用,react会使用render返回的虚拟DOM来创建真实DOM
实例化完成之后,响应用户操作和父组件的更新来更新视图。
1.componentWillRecieveProps
2.shouldComponentUpdate
3.componentWillUpdate
4.render
5.componentDidUpdate