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#3DES加密了解一下
    说说泛型
    工厂和抽象工厂
    装饰者模式(Decorator pattern)
    观察者模式(Observer pattern)
    策略模式(Stategy Pattern)
    C#读取Appconfig中自定义的节点
  • 原文地址:https://www.cnblogs.com/dobeco/p/11295274.html
Copyright © 2011-2022 走看看