• 初始React


      //在render前执行,并且执行一次
      componentWillMount() {
        console.log('willMount')
      }
      //在render后执行,且执行一次
      componentDidMount() {
        console.log("DidMount")
      }
      //初始化render不执行,props数据改变时触发
      componentWillReceiveProps(newProps) {
        console.log('newprops', newProps)
        return true
      }

      componentWillUpdate() {
        console.log('WillUpdate')
      }
      //在组件接受新的props之后触发
      componentDidUpdate() {
        console.log('DidUpdate')
      }
      //当调用setState的时候执行
      shouldComponentUpdate() {
        console.log('stateUpdate')
      }
     
     
    1. 组件将要挂载时触发的函数:componentWillMount
    2. 组件挂载完成时触发的函数:componentDidMount
    3. 是否要更新数据时触发的函数:shouldComponentUpdate
    4. 将要更新数据时触发的函数:componentWillUpdate
    5. 数据更新完成时触发的函数:componentDidUpdate
    6. 组件将要销毁时触发的函数:componentWillUnmount
    7. 父组件中改变了props传值时触发的函数:componentWillReceiveProps
  • 相关阅读:
    C#-使用Tuple传递多个参数
    CentOS 常用命令
    C#-ToString格式化
    java面对对象(六)--内部类、匿名内部类
    JAVA面对对象(五)——接口
    JAVA面对对象(四)——抽象类
    JAVA面对对象(三)——Super、static、final关键字
    Mybatis缓存
    重启博客
    某大神的装修笔记
  • 原文地址:https://www.cnblogs.com/huanhuan55/p/13525839.html
Copyright © 2020-2023  润新知