React生命周期
挂载
1、constructor 构造函数
2、static getDerivedStateFromProps
监听props更新state
3、render 渲染
4、componentDidMount
组件已挂载
更新
1、static getDerivedStateFromProps
监听props更新state
2、static getDerivedStateFromProps
监听props更新state
3、render 渲染函数
4、getSnapshotBeforeUpdate()
更新获取快照
返回的数据是cdu的第三个参数
5、componentDidUpdate
组件已经更新
卸载
1、componentWillunmount
组件将要卸载
如果这些React生命周期不能帮助你理解React生命周期,可以去React官网查看详细的解释。
React生命周期