Module: ReactWebpackRails::ViewHelpers
- Defined in:
- lib/react_webpack_rails/view_helpers.rb
Instance Method Summary collapse
Instance Method Details
#react_component(name, props = {}, options = {}, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/react_webpack_rails/view_helpers.rb', line 4 def react_component(name, props = {}, = {}, &block) = { tag: } if .is_a?(Symbol) = .reverse_merge(data: {}) [:data].tap do |data| data[:react_class] = name data[:react_props] = (props.is_a?(String) ? props : props.to_json) end html_tag = [:tag] || :div .except!(:tag) content_tag(html_tag, '', , &block) end |