React-rails: React::ServerRendering::PrerenderError in

Created on 3 Nov 2017  路  4Comments  路  Source: reactjs/react-rails

I am using Rails 5 with react-rails gem. I want to use server-side rendering, but I see this error:

React::ServerRendering::PrerenderError in Home#index

Encountered error "# ExecJS::ProgramError: TypeError: Cannot read property 'serverRender' of undefined" when prerendering Main with {}

This is javascripts/components.jsx:

class Main extends React.Component{ render(){ return ( <h1>Hello</h1> ); } }
and this is the view:
<%= react_component('Main', {}, {prerender: true}) %>
Without prerender option, everything works.

help wanted reproduction steps needed

Most helpful comment

Fixed. I execute command rails generate react:install and place components in /assets/javascripts/componets

All 4 comments

Hello @vladi160,

Are you using Webpacker or Sprockets?
Which version of React-Rails and which version of ReactRailsUJS do you have?

I'll help you if I can but I need to know more in order to replicate this issue. 馃憤

Fixed. I execute command rails generate react:install and place components in /assets/javascripts/componets

Thanks @ghost this solve my problem too.

This solves my problem too. +1 @ghost

Was this page helpful?
0 / 5 - 0 ratings