React组件Components的两种表示方式

函数式的表示:

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

Class式的表示:

class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}

对于React来说,上面这两种写法它认为是等价的。

原文地址:https://www.cnblogs.com/lishidefengchen/p/8653536.html