I'm not sure about the syntax you used. Please, replace the lines :

window.components ?= {}
window.components.Hello = Hello


window.Hello = Hello

(You can follow this link for further examples).


The problem is that for anything rendered with render_component it's required that the component is registered with the global window object. This is kind of not ideal but just how it works for the time being.

This is what I've been doing. Not ideal, but helps.

components /
    namespace /

Then doing this in my file:

# components/namespace/MyComponent.js.jsx

window.NamespaceMyComponent = React.createClass({});

module.exports = window.NamespaceMyComponent;

This last part allows me to use browserify and require my module like this:


and using the render_component helper like this:

<%= render_component "NamespaceMyComponent", {}, {prerender: true} %>

Related Query

More Query from same tag