react

1.生命周期

主要包含3个阶段 分别是挂载,更新,卸载

挂载阶段包含:

1.construct 数据初始化

2.componentWillMount render之前调用  代表已经初始化数据但是没有渲染dom,因此在此方法中同步调用setState不会被额外触渲染

3.getDerivedStateFromprops (componentWillReceiveProps) 在初始挂载和后续更新时都会被调用,返回一个对象更新state 如果返回null 不更新

4.render componentDidMount

更新阶段:

1.componentWillReceiveProps

2.shouldComponentUpdate 

3.componentWillUpdate

4.render

5.componentDidUpdate

卸载阶段:

comPonentWillUnmount

 

posted @ 2023-05-30 16:32  若栖1017  阅读(12)  评论(0编辑  收藏  举报