Próbuję sprawić, by ReactJS działał z szynami, korzystając z tego samouczka. Otrzymuję ten błąd:
Uncaught ReferenceError: React is not defined
Ale mogę uzyskać dostęp do obiektu React w konsoli przeglądarki.
Dodałem również public / dist / turbo-respons.min.js, jak opisano tutaj, a także dodałem wiersz w application.js, jak opisano w tej odpowiedzi, na brak szczęścia. Dodatkowo podaje błąd:
//= require components
var React = require('react')
Uncaught ReferenceError: require is not defined
Czy ktoś może mi zasugerować, jak rozwiązać ten problem?
[EDYCJA 1]
Kod źródłowy w celach informacyjnych:
to jest mój comments.js.jsxplik:
var Comment = React.createClass({
render: function () {
return (
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2>
{this.props.comment}
</div>
);
}
});
var ready = function () {
React.renderComponent(
<Comment author="Richard" comment="This is a comment "/>,
document.getElementById('comments')
);
};
$(document).ready(ready);
A to jest moje index.html.erb:
<div id="comments"></div>