【发布时间】:2016-03-18 15:19:31
【问题描述】:
我正在使用 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 的问题?
【问题讨论】:
标签: javascript ruby-on-rails ruby reactjs react-rails