ReactJS with CoffeeScript with Rails ReferenceError: <component> is not defined
ReactJS with CoffeeScript with Rails ReferenceError: <component> is not defined
我刚开始学习 ReactJS,从一开始我就有问题!
正如我所看到的,你说 React 与咖啡一起工作。
我的文件 hello.js.jsx.coffee
HelloWorld = React.createClass
render: ->
`<div>
<h1>Hello World!</h1>
</div>`
在我看来:
= react_component('HelloWorld', {}, :span)
但我得到错误:
ReferenceError: HelloWorld is not defined
我的应用示例是:
https://github.com/olegsobchuk/example_app
我正在使用 Rails 4.2.
所以,我找到了解决方法
改为
HelloWorld = React.createClass
.....
我们必须使用
@HelloWorld = React.createClass
render: ->
`<div>
<h1>Hello World!</h1>
</div>`
谢谢@rmosolgo!
我刚开始学习 ReactJS,从一开始我就有问题! 正如我所看到的,你说 React 与咖啡一起工作。 我的文件 hello.js.jsx.coffee
HelloWorld = React.createClass
render: ->
`<div>
<h1>Hello World!</h1>
</div>`
在我看来:
= react_component('HelloWorld', {}, :span)
但我得到错误:
ReferenceError: HelloWorld is not defined
我的应用示例是:
https://github.com/olegsobchuk/example_app
我正在使用 Rails 4.2.
所以,我找到了解决方法
改为
HelloWorld = React.createClass
.....
我们必须使用
@HelloWorld = React.createClass
render: ->
`<div>
<h1>Hello World!</h1>
</div>`
谢谢@rmosolgo!