(Note: I'm using the 'therubyracer', 'react-rails', and 'sprockets-coffee-react' gems)
This is the code for my simple component (Hello.js.cjsx):
# @cjsx React.DOM
Hello = React.createClass(
render: ->
<div>
Hello {@props.name || "World"}!
</div>
)
window.components ?= {}
window.components.Hello = Hello
In my rails view (index.html.erb) this works just fine:
<%= render_component('components.Hello', {name: 'Jack'}) %>
However, when I try this:
<%= react_component('components.Hello', {name: 'Jill'}, {prerender: true}) %>
I get this error:
Encountered error "ReferenceError: components is not defined"
which seems odd because I'm defining it in my component.
What am I doing wrong?