React Native的生命周期可以分为3个阶段,分别是初始化阶段、运行中阶段、销毁阶段,每个阶段对应的函数如下
什么是生命周期-组件的生命周期
组件本质上是状态机,输入确定,输出一定确定。状态发生转换时会触发不同的钩子函数,从而让开发者有机会做出响应
初始化阶段
- getDefaultProps
- getInitStateState
- componentWillMount;
- render
- componentDidMount
运行中阶段
- componentWillReceiveProps
组件将要接受到属性之前 - shouldComponentUpdate
- componentWillUpdate
- render
- componentDidUpdate
销毁阶段
- componentWillAmount
网友评论