我什么时候在反应类上使用组件?
看起来组件是一个类,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 { ... }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。