zhouzhongyuan / qa

Questions recods
MIT License
5 stars 1 forks source link

Stateless Functional Component是什么? #54

Open zhouzhongyuan opened 7 years ago

zhouzhongyuan commented 7 years ago

Stateless Functional Component:

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

ES6 Component:

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

使用

<Welcome name="Zhongyuan" />

延伸阅读

zhouzhongyuan commented 7 years ago

Advantage