Class: Webpacker::React::Component
- Inherits:
-
Object
- Object
- Webpacker::React::Component
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
- Defined in:
- lib/webpacker/react/component.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Component
constructor
A new instance of Component.
- #render(props = {}, options = {}) ⇒ Object
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
#name ⇒ Object
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 = {}, = {}) tag = .delete(:tag) || :div data = { data: { "react-class" => @name, "react-props" => props.to_json } } content_tag(tag, nil, .deep_merge(data)) end |