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

    contructor

    开始:

    getDefaultProps-->getInitialState-->componentWillMount-->render-->compononentDidMount

    props发生变化:

    componentWillReciveProps-->shouldCompomentUpdate-->false

    componentWillReciveProps-->shouldCompomentUpdate-->true-->componentWillUpdate-->render-->componentDidUpdate

    state发生变化:

    shouldCompomentUpdate-->false

    shouldCompomentUpdate-->true-->componentWillUpdate-->render-->componentDidUpdate

    卸载:

    componentWillUnmount-->结束

    componentWillMount 比较少使用,更多在服务器渲染时使用。

    componentDidMount 第一次渲染完执行。

    componentWillReciveProps 父组件传递值发生变化,接受一个nextProps可以跟当前的this.props对比

    shouldComponentUpdate(nextProps,nextState),用于性能优化

    新增的生命周期:getDerivedStateFromProps(nprops,nstates)

    代替componentWillReciveProps

    getSnapshotBeforeUpdate

    代替componentWillUpdate

  • 相关阅读:
    drf框架 APView的请求生命周期
    web API接口、restful规范
    vue项目安装插件配置
    vue项目、路由
    day67
    vue组件
    day66
    HDFS(Hadoop Distribute File System)
    JVM运行优化学习笔记
    ELK(检索)
  • 原文地址:https://www.cnblogs.com/baixinL/p/14976455.html
Copyright © 2011-2022 走看看