• react生命周期es6


    基本函数有

    import React from 'react'
    
    export default class MyClass extends React.Component {
      constructor(props){
        super(props)
        /**
         * 在这里生命当前页面的state
         */
        this.state = {
    
        }
      }
      /**
       * 第一次渲染前调用
       * 客户端和服务的都调用
       * 只调用一次
       * 可以调用this.setState
       */
      componentWillMount(){
    
      }
      /**
       * 在第一次渲染成功后调用
       * 可以得到dom节点 this.getDOMNode()
       * 客户端调用
       * 服务端不调用
       * 只调用一次
       */
      componentDidMount(){
    
      }
      /**
       * 组件将要接收新的props执行
       * @param {*} nextProps 
       */
      componentWillReceiveProps(nextProps){
    
      }
      /**
       * 判断组件是否应该重新渲染,默认是true
       * 一般返回true,这样在更新props或state才能重新渲染、
       * 返回false将不能重新渲染
       */
      shouldComponentUpdate(nextProps, nextState){
        return true
      }
      /**
       * 组件将要重新渲染
       */
      componentWillUpdate(){
    
      }
      /**
       * 组件重新渲染完成
       * 客户端有此生命周期方法
       * 服务器端没有
       * 
       */
      componentDidUpdate(){
    
      }
      /**
       * 卸载组件
       * 把一些监听事件卸载
       */
      componentWillUnmount(){
    
      }
      /**
       * 渲染组件
       * 必须有
       * 不可以用this.setState方法
       */
      render(){
        return (
          <div></div>
        )
      }
    }
    import React from 'react'

    export default class MyClass extends React.Component {
    constructor(props){
    super(props)
    /**
    * 在这里生命当前页面的state
    */
    this.state = {

    }
    }
    /**
    * 第一次渲染前调用
    * 客户端和服务的都调用
    * 只调用一次
    * 可以调用this.setState
    */
    componentWillMount(){

    }
    /**
    * 在第一次渲染成功后调用
    * 可以得到dom节点 this.getDOMNode()
    * 客户端调用
    * 服务端不调用
    * 只调用一次
    */
    componentDidMount(){

    }
    /**
    * 组件将要接收新的props执行
    * @param{*}nextProps
    */
    componentWillReceiveProps(nextProps){

    }
    /**
    * 判断组件是否应该重新渲染,默认是true
    * 一般返回true,这样在更新props或state才能重新渲染、
    * 返回false将不能重新渲染
    */
    shouldComponentUpdate(nextProps, nextState){
    return true
    }
    /**
    * 组件将要重新渲染
    */
    componentWillUpdate(){

    }
    /**
    * 组件重新渲染完成
    * 客户端有此生命周期方法
    * 服务器端没有
    *
    */
    componentDidUpdate(){

    }
    /**
    * 卸载组件
    * 把一些监听事件卸载
    */
    componentWillUnmount(){

    }
    /**
    * 渲染组件
    * 必须有
    * 不可以用this.setState方法
    */
    render(){
    return (
    <div></div>
    )
    }
    }
  • 相关阅读:
    mysql8.0.29 rpm安装步骤
    Django创建自定义命令
    BootStrap5应用时tooltips的添加
    mybatis相关转义字符串报错Cause: org.xml.sax.SAXParseException
    【资源共享】RK 单麦克语音通话 3A 算法集成说明及参数 调试说明文档
    k8s docker 中部署think php 并搭建php websocket
    .net core Unicode 转中文
    Webgl多层次模型
    小程序接口申请和隐私文档
    小程序开发入门
  • 原文地址:https://www.cnblogs.com/tongchuanxing/p/9266454.html
Copyright © 2020-2023  润新知