zoukankan      html  css  js  c++  java
  • React生命周期

    挂载

    • constructor
    • statc getDerivedStateFromProps
    • render
    • componentDidMount

    更新

    • static getDerivedStateFromProps
    • shoudComponentUpdate
    • render
    • getSnapshotBeforeUpdate
    • componentDidUpdate

    卸载

    • componentWillUnmount

    错误处理

    • getDerivedStateFromError
    • componentDidCatch

    常用生命周期

    • render
    • costructor 在react组件挂载之前调用
    • componentDidMount 组件挂载后立即调用
    • componentDdUpdate 更新后立即调用
    • componentWillUnmount 组件卸载及销毁后直接调用

    不常用生命周期

    • shouldComponentUpdate
    • static getDereivedStateFromProps 会在调用render方法之前调用,并且在初始挂载及后续更新都会被调用
    • getSnapshotBeforeUpdate 在最近一次渲染输出(提交到DOM节点)之前调用
    • Error boudaries 是react组件 它会在其子组件树中的任何位置捕获js错误,并记录这些错误
    • static getDerivedStateFromError 在后代组件抛出错误后被调用
    • componentDidCatch 在后代组件抛出错误后被调用

    过时的生命周期

    • componentWillMount 组件挂载前
    • componentWillReceiveProps 已挂载的组件接受到新的props之前被调用
    • componentWillUpdate 当组件接收到新的props或state时,会在渲染前调用

    建议生命周期

    • getDerivedStateFromProps
    • compomentDidMount
    • shouldComponentUpdate
    • getSnapShotBeforeUpdate
    • compomentDidUpdate
    • componentWillUnmount
    • componentDidUnMount
    • getSnapShotBeforetUpdate
  • 相关阅读:
    HashMap的存储原理
    HashSet的存储原理
    ArrayList的底层实现原理
    $.getJSON()不执行回调函数
    JavaScript学习笔记(一)
    【转】日语口语简略型总结(更新中。。。)
    计算机常用符号(日文)更新中。。。
    异常
    注解
    多线程
  • 原文地址:https://www.cnblogs.com/dobeco/p/11295274.html
Copyright © 2011-2022 走看看