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
  • 相关阅读:
    1008 Elevator (20)(20 分)
    1007 Maximum Subsequence Sum (25)(25 分)
    1006 Sign In and Sign Out (25)(25 分)
    酒店前台管理系统主要代码截图
    酒店前台管理系统
    酒店前台管理系统需求分析
    session与cookie的区别和联系
    ldap的实现单点登录
    git如何使用
    javaweb项目中的web.xml
  • 原文地址:https://www.cnblogs.com/dobeco/p/11295274.html
Copyright © 2011-2022 走看看