生命周期
componentWillMount 组件出现前 就是dom尚未渲染到html文档里面
componentDidMount 组件渲染完成 已经出如今dom文档里
能够再各个周期实现特定的操做html
生命周期的方法有:react
componentWillMount 在渲染前调用,在客户端也在服务端。框架
componentDidMount : 在第一次渲染后调用,只在客户端。以后组件已经生成了对应的DOM结构,能够经过this.getDOMNode()来进行访问。 若是你想和其余JavaScript框架一块儿使用,能够在这个方法中调用setTimeout, setInterval或者发送AJAX请求等操做(防止异部操做阻塞UI)。dom
componentWillReceiveProps 在组件接收到一个新的 prop (更新后)时被调用。这个方法在初始化render时不会被调用。this
shouldComponentUpdate 返回一个布尔值。在组件接收到新的props或者state时被调用。在初始化时或者使用forceUpdate时不被调用。 能够在你确认不须要更新组件时使用。component
componentWillUpdate在组件接收到新的props或者state但尚未render时被调用。在初始化时不会被调用。htm
componentDidUpdate 在组件完成更新后当即调用。在初始化时不会被调用。继承
componentWillUnmount在组件从 DOM 中移除的时候马上被调用。生命周期
React 组件生命周期:http://www.runoob.com/react/react-component-life-cycle.htmlip
React.Component:https://reactjs.org/docs/react-component.html#lifecycle-methods
构成与继承:https://reactjs.org/docs/composition-vs-inheritance.html
React组件生命周期过程说明:http://react-china.org/t/react/1740