React生命周期(旧版)

146 阅读1分钟

react生命周期旧版

微信图片_20220331220725.png

挂载阶段

constructor ==> 状态属性初始化

componentWillMount ==> 挂载前执行

render ==> 渲染组件

componentDidMount ==> 挂载后执行

更新阶段

componentWillReceiveProps ==> props更新执行

shouldComponentUpdate ==> props或state更新执行

componentWillUpdate ==> 更新前执行

render ==> 重新渲染组件

componentDidUpdate ==> 组件更新后执行

卸载阶段

componentWillUnmount ==> 组件卸载后执行

错误处理

componentDidCatch ==> 发生错误后执行