Class: ReactiveRuby::ServerRendering::ContextualRenderer

Inherits:
React::ServerRendering::BundleRenderer
  • Object
show all
Defined in:
lib/reactive-ruby/server_rendering/contextual_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ContextualRenderer

Returns a new instance of ContextualRenderer.



12
13
14
15
# File 'lib/reactive-ruby/server_rendering/contextual_renderer.rb', line 12

def initialize(options = {})
  super(options)
  ComponentLoader.new(v8_context).load
end

Instance Method Details

#before_render(*args) ⇒ Object



17
18
19
20
# File 'lib/reactive-ruby/server_rendering/contextual_renderer.rb', line 17

def before_render(*args)
  # the base class clears the log history... we don't want that as it is taken
  # care of in IsomorphicHelpers.load_context
end

#render(component_name, props, prerender_options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/reactive-ruby/server_rendering/contextual_renderer.rb', line 22

def render(component_name, props, prerender_options)
  if prerender_options.is_a?(Hash)
    if !v8_runtime? && prerender_options[:context_initializer]
      raise React::ServerRendering::PrerenderError.new(component_name, props, "you must use 'mini_racer' with the prerender[:context] option") unless v8_runtime?
    else
      prerender_options[:context_initializer].call v8_context
      prerender_options = prerender_options[:static] ? :static : true
    end
  end

  super(component_name, props, prerender_options)
end