私は反応レール gemを使用しています。このように見えるいくつかのコンポーネントをES6に書き込もうとしています。Rails-ReactがES6で動作しない
私はこの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.
が、これは私の問題ですエラーを取得しておくマイ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>
)
}
}
またはES6を正しくコンパイルしていないという宝石に問題がありますか?
私はRTFMをもっとよくするべきだと思います:Pこれは完璧でした –