Mounting组件挂载相关的
componentWillMount组件将要挂载。在render函数之前执行,只执行一次,即使多次重复渲染该组件,、
或者改变组件的state的值componentDidMount
组件已经挂载,在render之后执行,同一个组件重复渲染只执行一次
组件更新相关的
componentWillRecetiveProps(object,nextProps)已经加载组件收到新的props之前调用
,注意组件初始化渲染时不会执行
shouldComponentUpdate(Object nextProps,object nextState)
组件判断是否重新渲染时使用,该组件的接口实际是在组件接收到了新的props或者新的satate的
时候会立即调用
shouldComponentWillUpdate(Object nextProps,object nextState)组件将要更新
componentDidUpdate(Object prevProps,object prevState)
组件已经更新
组件移除
componentWillUnmount在组件将要被移除之前触发,利用该方法来执行一些必要的
清理组件
生命周期中和props和state相关的
getDefaultProps 设置props属性设置
getInitialState 升值state属性初始值
创建阶段只调用getDefaultProps:function()
在实例化阶段
getInitialState 设置this.state的默认值
componentWillMount 在render之前调用
render 渲染并返回一个虚拟的DOM
componentDidMount 在render之后调用,在该方法中react会使用render方法返回的虚拟的dom对象创建真实的DOM结构
可以在这个方法中读取dom结点
更新阶段
componentWillReceiveProps
shouldComponentUpdate 如果返回的是false后面的方法则不执行(是否需要更新)
componentWillUpdate
render
componentDidUpdate
销毁阶段
componentWillUnmount
移除组件
React.unmountComponentAtNode(挂载的对象)