我正在使用react-rails gem,我正在尝试在 ES6 中编写一些看起来像这样的组件。
我的link_list.js.jsx文件
import Component from 'react';
import Links from 'link';
class LinkList extends React.component{
constructor(props){
super(props);
this.sate = {};
}
getInitialState(){
return { links: this.props.initialLinks}
}
render(){
var links = this.state.links.map(function(link){
return <Links key={link.id} link={link} />
})
return (
<div className="links">
{links}
</div>
)
}
}
我不断收到这个Uncaught ReferenceError: require is not defined
和一个错误,上面写着Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
和错误Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
这是我的代码的问题还是 gem 没有编译 ES6 的问题?