组件的生命周期

2022-08-22  本文已影响0人  jancywen

挂载

组件实例被创建并插入到 DOM 中会触发挂载

  1. constructor
  2. componentWillMount
  3. render
  4. componentDidMount

更新

当组件的 props 或 state 发生变化时会触发更新

  1. componentWillReceiveProps
  2. shouldComponentUpdate
  3. componentWillUpdate
  4. render
  5. componentDidUpdate

卸载

当组件从 DOM 中移除时会触发卸载

  1. conponentWillUnmount
上一篇 下一篇

猜你喜欢

热点阅读