Sha256: 429f38a141ed1440b6a6478bd7a0df1aacad7462f24f585a46d5de823075a7f2

Contents?: true

Size: 905 Bytes

Versions: 5

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true

module React
  module Rails
    module ViewHelper
      # This class will be used for inserting tags into HTML.
      # It should implement:
      #   - #setup(controller_instance)
      #   - #teardown(controller_instance)
      #   - #react_component(name, props, options &block)
      # The default is {React::Rails::ComponentMount}
      mattr_accessor :helper_implementation_class

      # Render a React component into the view
      # using the {helper_implementation_class}
      #
      # If called during a Rails controller-managed request, use the instance
      # created by the controller.
      #
      # Otherwise, make a new instance.
      def react_component(*args, &block)
        helper_obj = @__react_component_helper ||= helper_implementation_class.new
        helper_obj.react_component(*args) { capture(&block) if block }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
react-rails-3.2.0 lib/react/rails/view_helper.rb
react-rails-3.1.1 lib/react/rails/view_helper.rb
react-rails-3.1.0 lib/react/rails/view_helper.rb
react-rails-3.0.0 lib/react/rails/view_helper.rb
react-rails-3.0.0.rc.0 lib/react/rails/view_helper.rb