lib/ReactRenderAnywhere.rb in react-render-anywhere-helper-0.1.1 vs lib/ReactRenderAnywhere.rb in react-render-anywhere-helper-0.1.2

- old
+ new

@@ -1,10 +1,17 @@ require "ReactRenderAnywhere/version" module ReactRenderAnywhere - def self.render_component(name, element, props:) - content_for(:javascripts) do - render partial: "common/react_render_anywhere", locals: { name: name, element: element, props: props } - end - content_tag(:div, nil, :class=>"react-render-anywhere", :id=>element) + def render_component(name, element, props:) + content_tag( + :div, + "<script> + reactComponents.default.render({ + component: '#{name}', + props: #{props.to_json()}, + element: document.getElementById('#{element}'), + }) + </script>".html_safe, + :class=>"react-render-anywhere", :id=>element + ) end end