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

React组件继承的由来

时间:2018-01-02 21:25:29      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:由来   int   port   span   set   arp   body   word   ext   

没有显式继承的时候我们这么写:

import * as React from "react";

export interface HelloProps { compiler: string; framework: string; }

export const Hello = (props: HelloProps) => <h1>Hello from {props.compiler} and {props.framework}!</h1>;

我们把它写的更像类一些:

import * as React from "react";

export interface HelloProps { compiler: string; framework: string; }

// ‘HelloProps‘ describes the shape of props.
// State is never set so we use the ‘{}‘ type.
export class Hello extends React.Component<HelloProps, {}> {
    render() {
        return <h1>Hello from {this.props.compiler} and {this.props.framework}!</h1>;
    }
}

  

React组件继承的由来

标签:由来   int   port   span   set   arp   body   word   ext   

原文地址:https://www.cnblogs.com/yk123/p/8178699.html

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