码迷,mamicode.com
首页 > 其他好文 > 详细

React 学习(二) 类组件的props

时间:2020-12-01 12:16:33      阅读:4      评论:0      收藏:0      [点我收藏+]

标签:fun   subclass   com   cto   port   div   UNC   can   component   

super

  • super(props): Superclass will help you to keep the props:[^ props]

    import React, { Component } from "react";
    export default class App extends Component {
      constructor(props) {
        super(props);
      }
    
      render() {
        return (
          <div>App</div>
        );
      }
    }
    
  • But we use super() also can run

    import React, { Component } from "react";
    export default class App extends Component {
      constructor() {
        super();
      }
      render() {
        return (
          <div>
            App
          </div>
        );
      }
    }
    
  • Subclass will auto execute the constructor function, we can not write it

    import React, { Component } from "react";
    export default class App extends Component {
      render() {
        return (
          <div>App</div>
        );
      }
    }
    

React 学习(二) 类组件的props

标签:fun   subclass   com   cto   port   div   UNC   can   component   

原文地址:https://www.cnblogs.com/smallstars/p/14043521.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!