Sha256: 722e370d39d232dc92e0a2ffa1bfc2bb8d01081fb8667f15c5bf3596b863493e

Contents?: true

Size: 1.25 KB

Versions: 22

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module ReactOnRails
  module ServerRenderingJsCode
    class << self
      def js_code_renderer
        @js_code_renderer ||= if ReactOnRails::Utils.react_on_rails_pro?
                                ReactOnRailsPro::ServerRenderingJsCode
                              else
                                self
                              end
      end

      def server_rendering_component_js_code(
        props_string: nil,
        rails_context: nil,
        redux_stores: nil,
        react_component_name: nil,
        render_options: nil
      )
        js_code_renderer.render(props_string, rails_context, redux_stores, react_component_name, render_options)
      end

      def render(props_string, rails_context, redux_stores, react_component_name, render_options)
        <<-JS
        (function() {
          var railsContext = #{rails_context};
        #{redux_stores}
          var props = #{props_string};
          return ReactOnRails.serverRenderReactComponent({
            name: '#{react_component_name}',
            domNodeId: '#{render_options.dom_id}',
            props: props,
            trace: #{render_options.trace},
            railsContext: railsContext
          });
        })()
        JS
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
react_on_rails-12.4.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.4.0.rc.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.3.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.2.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.1.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.5.beta.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.4 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-11.3.1 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-11.3.1.beta.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.3 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.3.beta.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.2 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.1 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.0.pre.beta.4 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.0.pre.beta.3 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.0.pre.beta.2 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.0.pre.beta.1 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-12.0.0.pre.beta.0 lib/react_on_rails/server_rendering_js_code.rb
react_on_rails-11.3.0 lib/react_on_rails/server_rendering_js_code.rb