Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ MyApp::Application.configure do
config.react.timeout = 20
# where to get React.js source:
config.react.react_js = lambda { File.read(::Rails.application.assets.resolve('react.js')) }
# where to get JSXTransformer.js
config.react.jsx_transformer_js = lambda { File.read(::Rails.application.assets.resolve('JSXTransformer.js')) }
# array of filenames that will be requested from the asset pipeline
# and concatenated:
config.react.component_filenames = ['components.js']
Expand Down
4 changes: 2 additions & 2 deletions lib/react/jsx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module React
module JSX
mattr_accessor :transform_options
mattr_accessor :transform_options, :jsx_transformer_js

def self.context
# lazily loaded during first request and reloaded every time when in dev or test
Expand All @@ -17,7 +17,7 @@ def self.context

# search for transformer file using sprockets - allows user to override
# this file in his own application
File.read(::Rails.application.assets.resolve('JSXTransformer.js'))
jsx_transformer_js.call

@context = ExecJS.compile(contents)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/react/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Railtie < ::Rails::Railtie
config.react.max_renderers = 10
config.react.timeout = 20 #seconds
config.react.react_js = lambda {File.read(::Rails.application.assets.resolve('react.js'))}
config.react.jsx_transformer_js = lambda {File.read(::Rails.application.assets.resolve('JSXTransformer.js'))}
config.react.component_filenames = ['components.js']

# Watch .jsx files for changes in dev, so we can reload the JS VMs with the new JS code.
Expand Down Expand Up @@ -71,6 +72,7 @@ class Railtie < ::Rails::Railtie

do_setup = lambda do
cfg = app.config.react
React::JSX.jsx_transformer_js = cfg.jsx_transformer_js
React::Renderer.setup!( cfg.react_js, cfg.components_js, cfg.replay_console,
{:size => cfg.max_renderers, :timeout => cfg.timeout})
end
Expand Down