1.初始化initialization
2.挂载mounting
挂载前
挂载中render
已经挂载
控制台输出
可见执行顺序为预加载componentWillMount ——> 渲染render ——> 挂载 componentDidMount
3.更新Updation
true为需要更新,false是不需要更新
componentWillUpdate执不执行取决于shouldComponent的返回值是否为true,true就执行,false不执行
componentDidUpdated;组件更新完成之后会被执行
componentWillReceiveProps
//当一个组件从父组件接收到了参数
//只要父组件的render函数被重新执行了,
componentWillReceiveProps() {
console.log('componentWillReceiveProps')
}
4.Unmounting把一个组件去除
componentWillUnmount()当一个组件即将被去除会被执行
componentWillUnmount() {
console.log('componentWillUnmount')
}