我什么时候在反应类上使用组件?
看起来组件是一个类,createClass创建一个组件。
https://facebook.github.io/react/docs/top-level-api.html
React.Component
This is the base class for React Components when they’re defined using
ES6 classes. See Reusable Components for how to use ES6 classes with
React. For what methods are actually provided by the base class,see
the Component API.
React.createClass
Create a component class,given a specification. A component
implements a render method which returns one single child. That child
may have an arbitrarily deep child structure. One thing that makes
components different than standard prototypal classes is that you
don’t need to call new on them. They are convenience wrappers that
construct backing instances (via new) for you.
React.createClass是一个返回一个Component类的函数。
MyComponent = React.createClass({ ... });
React.Component是您可以扩展的现有组件。当使用ES6时主要有用。
MyComponent extends React.Component { ... }