vendredi 3 novembre 2017

React::ServerRendering::PrerenderError in... Rails 5, React

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 my /assets/javascripts/application.js:

//= require rails-ujs
//= require jquery
//= require react
//= require react_ujs
//= require_tree .

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.

Aucun commentaire:

Enregistrer un commentaire