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
  • 相关阅读:
    今天不谈技术,谈感情~
    外派金融公司
    OAuth2-简介
    Zookeeper实战-分布式锁
    Zookeeper-基础
    Minio-对象存储
    Redis实战-BloomFilter
    Redis实战-详细配置-优雅的使用Redis注解/RedisTemplate
    Redis-基础
    SpringBoot-表单验证-统一异常处理-自定义验证信息源
  • 原文地址:https://www.cnblogs.com/dobeco/p/11295274.html
Copyright © 2011-2022 走看看