Używam gem Reakcja-Rails i staram się napisać kilka komponentów w ES6, które wyglądają tak.Rails-React nie działa z ES6
Moja link_list.js.jsx plik
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>
)
}
}
Wciąż dostaję ten Uncaught ReferenceError: require is not defined
i błąd, który mówi 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).
i błąd Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Czy to problem z moim kod lub czy jest problem z klejnotem, który nie kompiluje ES6?
Chyba powinienem RTFM więcej haha: P dziękuję, to było idealne –