Tôi đang sử dụng đường kính phản ứng - và tôi đang cố gắng viết một vài thành phần trong ES6 giống như thế này.Rails-React không hoạt động với ES6
My link_list.js.jsx tập tin
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>
)
}
}
tôi tiếp tục nhận được Uncaught ReferenceError: require is not defined
này và một lỗi mà nói 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).
và lỗi Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
này một vấn đề với tôi là mã hoặc là nó là một vấn đề với đá quý không biên dịch ES6 phải không?
Tôi đoán tôi nên RTFM haha hơn: P cảm ơn bạn này là hoàn hảo –