module ReactRenderAnywhere
Constants
- VERSION
Public Class Methods
new(build_name:)
click to toggle source
# File lib/ReactRenderAnywhere.rb, line 4 def self.new(build_name:) @build_name = build_name self end
render_component(name, element, props:)
click to toggle source
# File lib/ReactRenderAnywhere.rb, line 9 def self.render_component(name, element, props:) ActionController::Base.helpers.content_tag( :div, "<script> #{@build_name}.default.render({ component: '#{name}', props: #{props.to_json()}, element: document.getElementById('#{element}'), }) </script>".html_safe, :class=>"react-render-anywhere", :id=>element ) end