React生命周期


React声明周期的四个大阶段:

 1-Initialization:初始化阶段。

 2-Mounting: 挂载阶段。

 3-Updation: 更新阶段。

    4-Unmounting: 销毁阶段

Mounting阶段

    Mounting阶段叫挂载阶段,伴随着整个虚拟DOM的生成,它里边有三个小的生命周期函数,分别是:

 1-componentWillMount : 在组件即将被挂载到页面的时刻执行。

 2-render : 页面state或props发生变化时执行。

 3-componentDidMount : 组件挂载完成时被执行。

Updation阶段

1-shouldComponentUpdate---组件发生改变前执行(可以返回true或者false)
2-componentWillUpdate---组件更新前,shouldComponentUpdate函数之后执行
3-render----开始挂载渲染
4-componentDidUpdate----组件更新之后执行

Unmounting阶段

1-componentWillUnmount---组件去除时执行



posted @ 2019-11-19 16:20  林玖女神  阅读(94)  评论(0编辑  收藏  举报