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.
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
Most helpful comment
Fixed. I execute command
rails generate react:installand place components in/assets/javascripts/componets