Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Barone committed Oct 1, 2024
1 parent 1e7ddf2 commit 678ebfd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/react_on_rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ def react_component(component_name, options = {}, &block)
# <% end %>
# <%= react_helmet_app["componentHtml"] %>
#
def react_component_hash(component_name, options = {})
def react_component_hash(component_name, options = {}, &block)
(options[:props] ||= {})[:children_html] = capture(&block) if block
options[:prerender] = true

internal_result = internal_react_component(component_name, options)
server_rendered_html = internal_result[:result]["html"]
console_script = internal_result[:result]["consoleReplayScript"]
Expand Down
10 changes: 10 additions & 0 deletions spec/dummy/client/app/startup/ChildrenExample.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

const ComponentWithChildren = ({ children }) => (
<div>
<h1>This is component for testing passing children in from Rails</h1>
{ children }
</div>
);

export default ComponentWithChildren;

0 comments on commit 678ebfd

Please sign in to comment.