4

我正在尝试通过以下方式打开 react-on-rails 上的服务器端渲染:

<%= react_component("App", props: @props, prerender: true) %>

但我收到了这个错误:

ERROR in SERVER PRERENDERING
Encountered error: "uninitialized constant #<Class:0x00007fe22a217898>::ExecJS"
when prerendering App with props: {"app_name":"application","name":"Stranger"}

代码:

var railsContext = {"railsEnv":"development","inMailer":false,"i18nLocale":"en","i18nDefaultLocale":"en","rorVersion":"11.2.1","rorPro":false,"href":"http://localhost:3000/","location":"/","scheme":"http","host":"localhost","port":3000,"pathname":"/","search":null,"httpAcceptLanguage":"en-US,en;q=0.9","serverSide":true};
ReactOnRails.clearHydratedStores();

var props = {"app_name":"application","name":"Stranger"};
  return ReactOnRails.serverRenderReactComponent({
    name: 'App',
    domNodeId: 'App-react-component-d03e2041-2851-4a23-9be0-b42bf2f6749d',
    props: props,
    trace: true,
    railsContext: railsContext
  });
}
4

0 回答 0