module React::Rails::ControllerLifecycle
This module is included into ActionController so that per-request hooks can be called in the view helper.
Attributes
__react_component_helper[R]
Public Instance Methods
per_request_react_rails_prerenderer() { || ... }
click to toggle source
If you want a per-request renderer, add this method as an around-action
(‘.per_request_react_rails_prerenderer` does this for you) @example Having one renderer instance for each controller action
around_action :per_request_react_rails_prerenderer
# File lib/react/rails/controller_lifecycle.rb, line 40 def per_request_react_rails_prerenderer React::ServerRendering.with_renderer do |renderer| @__react_rails_prerenderer = renderer yield end end
react_rails_prerenderer()
click to toggle source
An instance of a server renderer, for use during this request
# File lib/react/rails/controller_lifecycle.rb, line 48 def react_rails_prerenderer @__react_rails_prerenderer end
use_react_component_helper() { || ... }
click to toggle source
Instantiate the ViewHelper
implementation and call its setup method then let the controller action run, then call the ViewHelper
implementation’s teardown method
# File lib/react/rails/controller_lifecycle.rb, line 27 def use_react_component_helper new_helper = React::Rails::ViewHelper.helper_implementation_class.new new_helper.setup(self) @__react_component_helper = new_helper yield @__react_component_helper.teardown(self) end