组件的生命周期就是一个组件从创建到销毁的整个过程。

一、Mounting 只调用一次

1、定义一个组件的默认属性

     getDefaultProps (es5)

      static defaultProps (es6)

2、组件初始化

    getInitialState (es5)

    constructor(props) (es6)

3、组件渲染前 componentWillMount

4、组件渲染 render

5、组件渲染完成 componentDidMount

二、运行中 (updating) 多次调用

1、属性(props)改变  componentWillReceiveProps -> shouldComponentUpdate

2、是否渲染组件 shouldComponentUpdate -> 

       true -> componentWillUpdate-> render -> componentDidUpdate

       false -> 运行中

3、状态(state)改变 -> shouldComponentUpdate

三、卸载(Unmount) 只调用一次

     componentWillUnmount

React Native中组件的生命周期



相关文章:

  • 2021-12-31
  • 2021-12-18
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2022-01-19
  • 2022-01-18
  • 2021-06-22
  • 2022-12-23
  • 2021-05-20
  • 2021-10-18
  • 2021-08-29
相关资源
相似解决方案