mounting时期
- componentWillMount 在组件即将被挂载到页面的那个时刻自动执行
- render 第一次渲染的时候也要执行当state或者props的数据改变的时候也会被执行
- componentDidMount 在组件被挂载到页面之后被自动执行
updating时期(即state或者props中的数据发生的时候执行的)
- shouldComponentUpdate(nextProps, nextState) 在组件更新之前被自动执行,必须返回一个Boolean值的数据。
- componentWillUpdate 在组件更新之且在shouldComponentUpdate之后被自动执行,如 果shouldComponentUpdate返回的时false, 就不再执行该生命周期函数
- rende函数也会被执行
- componentDidUpdate 在组件更新完成之后被执行。
- componentWillReceiveProps 一个组件从父组件中接收参数,首次在父组件渲染不会被 执行,第二次才会被执行
unMounting时期
- componentWillUnmount 组件被页面移除之前执行