Reputation: 2472
I'm using the react-rails gem in a project.
Whenever I pass in the {prerender: true} in react_component helper, I am getting this error :
Encountered error "ReferenceError: ReactDOMServer is not defined" when prerendering UsersList with
Upvotes: 1
Views: 2634
Reputation: 66
I have the same issue and haven't found a proper solution. I created an issue on the github repo of the gem. So far there's a workaround (for an other issue but it worked for me):
Copy/pasted from issue #443
Rails.application.config.assets.precompile += %w( components.js )
)//= require react-server
to your components.js fileSpecify only components.js for server rendering:
config.react.server_renderer_options = {
files: ["components.js"], # files to load for prerendering
}
UPDATE:
Downgrading the following gems: sprockets (2.12.4) and sprockets-rails (2.3.3) seems to avoid the issue.
Upvotes: 5