1

I am using react-rails, and I'm trying to render server side using the prerender option:

<%= react_component('MyComponent', @data, {prerender: true}) %>

When I do this, I get an error as a result of const:

Exception: SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.

The const keyword, IIUC, is available in ES6, so it needs to be transpiled in some way. I'm trying to figure out how to tell react-rails to transpile the ES6. It seems like config.react.jsx_transform_options is the way to specify, it, but I've added the following to application.rb and it does not have any effect:

application.rb:

config.react.jsx_transform_options = {
  whitelist: [
    "es6.constants",
  ],
}

What am I doing wrong here?

Leonid Beschastny
  • 50,364
  • 10
  • 118
  • 122
Sam Lee
  • 9,913
  • 15
  • 48
  • 56

0 Answers0