File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
packages/react-on-rails-pro/src Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,15 @@ export type RSCRouteProps = {
7777
7878const PromiseWrapper = ( { promise } : { promise : Promise < React . ReactNode > } ) => {
7979 // React.use is available in React 18.3+
80- return React . use ( promise ) ;
80+ const promiseResult = React . use ( promise ) ;
81+
82+ // In case that an error happened during the rendering of the RSC payload before the rendering of the component itself starts
83+ // RSC bundle will return an error object serilaized inside the RSC payload
84+ if ( promiseResult instanceof Error ) {
85+ throw promiseResult ;
86+ }
87+
88+ return promiseResult ;
8189} ;
8290
8391const RSCRoute = ( { componentName, componentProps } : RSCRouteProps ) : React . ReactNode => {
Original file line number Diff line number Diff line change 1- import * as React from 'react' ;
21import { ErrorOptions } from 'react-on-rails/types' ;
32import { renderToPipeableStream } from 'react-on-rails-rsc/server.node' ;
43import generateRenderingErrorMessage from 'react-on-rails/generateRenderingErrorMessage' ;
54
65const handleError = ( options : ErrorOptions ) => {
76 const msg = generateRenderingErrorMessage ( options ) ;
8- const reactElement = React . createElement ( 'pre' , null , msg ) ;
9- return renderToPipeableStream ( reactElement , {
7+ return renderToPipeableStream ( new Error ( msg ) , {
108 filePathToModuleMetadata : { } ,
119 moduleLoading : { prefix : '' , crossOrigin : null } ,
1210 } ) ;
You can’t perform that action at this time.
0 commit comments