Tekkaman

导航

 

Functional and Class Components

  The simplest way to define a component is to write a JavaScript function:

  

  This function is a valid React component because it accepts a single "props" object argument with data and returns a React element. We call such components "functional" because they are literally JavaScript functions.

  You can also use an ES6 class to define a component:

  

  

  The above two components are equivalent from React's point of view.

 

参考:https://facebook.github.io/react/docs/components-and-props.html#functional-and-class-components

posted on 2017-03-21 11:37  Tekkaman  阅读(225)  评论(0编辑  收藏  举报