1

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

Akshay Borade
  • 2,442
  • 12
  • 26

1 Answers1

5

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

  1. Make sure components.js is compiled (Rails.application.config.assets.precompile += %w( components.js ))
  2. Add //= require react-server to your components.js file
  3. Specify 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.

Benigno H
  • 66
  • 2