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
  • 相关阅读:
    (C/C++)区别:数组与指针,指针与引用
    C++中数组名和指针的区别联系
    C++引用的用处
    C++编写DLL动态链接库的步骤与实现方法
    C++_编写动态链接库
    C++ 模板
    C++ 信号处理
    C++ 多线程
    js事件冒泡
    js事件委托
  • 原文地址:https://www.cnblogs.com/dobeco/p/11295274.html
Copyright © 2011-2022 走看看