react 生命周期钩子函数

实例化

  • construtor//构造函数
  • componentWillMount//挂载之前,可修改setState
  • render//渲染真实dom
  • componentDidMount//第一次render后,仅一次,可setState

存在期

  • componentWillReceiveProps//父组件render时props更新时,不管props是否变化
  • shouldComponentUpdate//修改state后自动调用,默认返回true,false跳过后面的,少用
  • componentWillUpdate//修改state的render之前自动调用,相似于CWM
  • render
  • componentDidUpdate//render后调用,万不得已不要修改state死循环

销毁期

  • componentWillUnmount//销毁前

猜你喜欢

转载自www.cnblogs.com/liqunblog/p/8979242.html