File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -102,13 +102,23 @@ def stream_react_component(component_name, options = {})
102102 end
103103
104104 def stream_react_component_async ( component_name , options = { } )
105- Fiber . new do
105+ rendering_fiber = Fiber . new do
106106 stream = stream_react_component ( component_name , options )
107107 stream . each_chunk do |chunk |
108108 Fiber . yield chunk
109109 end
110110 Fiber . yield nil
111111 end
112+
113+ if @rorp_rendering_fibers . nil?
114+ raise ReactOnRails ::Error , "You must call stream_view_containing_react_components to render the view containing the react component"
115+ end
116+ @rorp_rendering_fibers << rendering_fiber
117+
118+ # return the first chunk of the fiber
119+ # It contains the initial html of the component
120+ # all updates will be appended to the stream sent to browser
121+ rendering_fiber . resume
112122 end
113123
114124 # react_component_hash is used to return multiple HTML strings for server rendering, such as for
You can’t perform that action at this time.
0 commit comments