lib/react/rails/controller_renderer.rb in react-rails-1.10.0 vs lib/react/rails/controller_renderer.rb in react-rails-1.11.0
- old
+ new
@@ -1,11 +1,12 @@
module React
module Rails
# A renderer class suitable for `ActionController::Renderers`.
# It is associated to `:component` in the Railtie.
#
- # It is prerendered with {React::ServerRendering}.
+ # It is prerendered by default with {React::ServerRendering}.
+ # Set options[:prerender] to `false` to disable prerendering.
#
# @example Rendering a component from a controller
# class TodosController < ApplicationController
# def index
# @todos = Todo.all
@@ -22,14 +23,20 @@
def initialize(options={})
controller = options[:controller]
@__react_component_helper = controller.__react_component_helper
end
- # @return [String] Prerendered HTML for `component_name` with `options[:props]`
+ # @return [String] HTML for `component_name` with `options[:props]`
def call(component_name, options, &block)
props = options.fetch(:props, {})
- options = options.slice(:data, :aria, :tag, :class, :id).merge(prerender: true)
+ options = default_options.merge(options.slice(:data, :aria, :tag, :class, :id, :prerender))
react_component(component_name, props, options, &block)
+ end
+
+ private
+
+ def default_options
+ { prerender: true }
end
end
end
end