Class: Webpacker::React::Component

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
Defined in:
lib/webpacker/react/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Component

Returns a new instance of Component.



9
10
11
# File 'lib/webpacker/react/component.rb', line 9

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/webpacker/react/component.rb', line 7

def name
  @name
end

Instance Method Details

#render(props = {}, options = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/webpacker/react/component.rb', line 13

def render(props = {}, options = {})
  tag = options.delete(:tag) || :div
  data = { data: { "react-class" => @name, "react-props" => props.to_json } }

  (tag, nil, options.deep_merge(data))
end