Sha256: 978d0c06121f175c570f83d69be15a28346b431e765bd3358f3c8bb258c81b5f

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

begin
  
  require 'react-rails'
  require 'reactive-ruby' #'/prerender_data_interface'
  
  module React
    module Rails
      module ViewHelper

        alias_method :pre_opal_react_component, :react_component

        def react_component(module_style_name, props = {}, render_options={}, &block)
          js_name = module_style_name.gsub("::", ".")
          if render_options[:prerender]
            render_options[:prerender] = {render_options[:prerender] => true} unless render_options[:prerender].is_a? Hash
            existing_context_initializer = render_options[:prerender][:context_initializer]
            render_options[:prerender][:context_initializer] = lambda do |ctx| 
              React::IsomorphicHelpers.load_context(ctx, self)
              existing_context_initializer.call ctx if existing_context_initializer
            end
            
          end
          component_rendering = raw(pre_opal_react_component(js_name, props.react_serializer, render_options, &block))
          footers = React::IsomorphicHelpers.prerender_footers #if render_options[:prerender]
          component_rendering+footers
        end
      end
    end
  end
  
rescue LoadError
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reactive-ruby-0.7.3 lib/rails-helpers/react_component.rb