File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,9 @@ module Helper
53
53
# Any other options are passed to the content tag, including the id.
54
54
# random_dom_id can be set to override the default from the config/initializers. That's only
55
55
# used if you have multiple instance of the same component on the Rails view.
56
- def react_component ( component_name , options = { } )
56
+ def react_component ( component_name , options = { } , &block )
57
+ ( options [ :props ] ||= { } ) [ :children_html ] = capture ( &block ) if block
58
+
57
59
internal_result = internal_react_component ( component_name , options )
58
60
server_rendered_html = internal_result [ :result ] [ "html" ]
59
61
console_script = internal_result [ :result ] [ "consoleReplayScript" ]
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ export default function createReactOutput({
26
26
} : CreateParams ) : CreateReactOutputResult {
27
27
const { name, component, renderFunction } = componentObj ;
28
28
29
+ const children = props ?. children_html ? React . createElement ( 'div' , { dangerouslySetInnerHTML : { __html : props . children_html } } ) : null ;
30
+
29
31
if ( trace ) {
30
32
if ( railsContext && railsContext . serverSide ) {
31
33
console . log ( `RENDERED ${ name } to dom node with id: ${ domNodeId } ` ) ;
@@ -68,8 +70,8 @@ work if you return JSX. Update by wrapping the result JSX of ${name} in a fat ar
68
70
69
71
// If a component, then wrap in an element
70
72
const reactComponent = renderFunctionResult as ReactComponent ;
71
- return React . createElement ( reactComponent , props ) ;
73
+ return React . createElement ( reactComponent , props , children ) ;
72
74
}
73
75
// else
74
- return React . createElement ( component as ReactComponent , props ) ;
76
+ return React . createElement ( component as ReactComponent , props , children ) ;
75
77
}
You can’t perform that action at this time.
0 commit comments