• react生命周期


    import React, {Component} from 'react';
    
    class LifeCycle extends Component {
    
        // [基本流程]
        // constructor 创建一个组件
        constructor(props) {
            super(props);
            console.log('constructor');
        }
        // componentWillMount 第一次渲染之前
        componentWillMount() {
            console.log('componentWillMount');
        }
        // componentDidMount 第一次渲染之后
        componentDidMount() {
            console.log('componentDidMount');
        }
        // render 第一次渲染
        render() {
            console.log('render');
            return (<div>LifeCycle</div>);
        }
    
        // [修改流程:当组件的状态数据发生改变时]
    
        // shouldComponentUpdate 是否允许组件渲染
        shouldComponentUpdate(nextProps, nextState, nextContext) {
        }
    
        // componentWillUpdate 重新渲染之前
        componentWillUpdate(nextProps, nextState, nextContext) {
        }
        // componentDidUpdate 重新渲染之后
        componentDidUpdate(prevProps, prevState, snapshot) {
        }
    
        // componentWillReceiveProps 父组件把传递给子组件的的属性发生改变后触发的钩子函数
        componentWillReceiveProps(nextProps, nextContext) {
        }
        
        // [销毁]
        
        // componentWillUnmount 卸载组件
        componentWillUnmount() {
        }
    }
    
    export default LifeCycle;
    
  • 相关阅读:
    软件包的作用
    Sqlserver2008 表分区教程
    C#通用类型转换 Convert.ChangeType
    缓存 HttpContext.Current.Cache和HttpRuntime.Cache的区别
    用户信息 Froms验证票证
    .NET4.0 __doPostBack未定义
    TFS2012 安装 配置笔记
    MVC学习笔记一
    新博客..第一天..
    ORACLE多表查询优化
  • 原文地址:https://www.cnblogs.com/korea/p/12023717.html
Copyright © 2020-2023  润新知