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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

which files did you change for #1 and #3 above?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.