zoukankan      html  css  js  c++  java
  • react组件生命周期

    1. Mounting/组建挂载相关

      (1)componentWillMount

        组件将要挂载。在render之前执行,但仅执行一次,即使多次重复渲染该组件或者改变了组件的state

      (2)componentDidMount

        组件已经挂载。在render之后执行,同一个组件重复渲染只执行一次。

    2. Updating/组建更新相关

      (1)componentWillReceiveProps(object nextProps)

        已加载组件收到新的props之前调用,注意组件初始化渲染时则不会执行

      (2)shouldComponentUpdate(object nextProps, object nextState)

        组件判断是否重新渲染时调用。该接口实际是在组件接收到了新的props或者新的state的时候会立即调用

      (3)componentWillUpdate(object nextProps, object nextState)

        组件将要更新

      (4)componentDidUpdate(object nextProps, object nextState)

        组建已经更新

    3. Unmounting/组件移除相关

      (1)componentWillUnmount

        在组件要被移除之前的时间点触发,可以利用该方法来执行一些必要的清理

    4. 生命周期中与props和state相关

      (1)getDefaultProps  设置props属性默认值

      (2)getInitialState      设置state属性初始值  

  • 相关阅读:
    Linux--shell三剑客<sed>--07
    Linux--shell交互输入与循环语句--06
    Linux--shel分支语句--05
    Linux--shell grep与正则表达式--04
    Linux--shell编程原理--03
    Linux--shell重定向与文件处理命令--02
    Linux--shell的基本特性--01
    Docker数据卷
    Docker容器
    Docker的安装
  • 原文地址:https://www.cnblogs.com/ImaY/p/9037383.html
Copyright © 2011-2022 走看看