Using react-rails within your application

suggest change

React.js builds

You can pick which React.js build (development, production, with or without add-ons) to serve in each environment by adding a config. Here are the defaults:

# config/environments/development.rb
MyApp::Application.configure do
  config.react.variant = :development
end
# config/environments/production.rb
MyApp::Application.configure do
  config.react.variant = :production
end

To include add-ons, use this config:

MyApp::Application.configure do
  config.react.addons = true # defaults to false
end

After restarting your Rails server, //= require react provides the build of React.js specified by that configuration.

react-rails offers a few other options for versions and builds of React.js. See VERSIONS.md for using the react-source gem or dropping in your own copies of React.js.

JSX

After installing react-rails, restart your server. Now, .js.jsx files will be transformed in the asset pipeline.

BabelTransformer options

You can use Babel’s transformers and custom plugins, and pass options to the Babel transpiler, by adding the following configuration:

config.react.jsx_transform_options = {
  blacklist: ["spec.functionName", "validation.react", "strict"], # default options
  optional: ["transformerName"], # extra Babel options
  whitelist: ["useStrict"]
}

Under the hood, react-rails uses ruby-babel-transpiler, for transformation.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents