Skip to content

Commit

Permalink
fix: react router error is not Array but Object constructor (#6585)
Browse files Browse the repository at this point in the history
  • Loading branch information
zllkjc authored Nov 29, 2024
1 parent 30f77f6 commit e220a13
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export const routerPlugin = (
if (routerContext instanceof Response) {
// React Router would return a Response when redirects occur in loader.
// Throw the Response to bail out and let the server handle it with an HTTP redirect

return interrupt(routerContext);
}

Expand All @@ -131,10 +130,14 @@ export const routerPlugin = (
if (
routerContext.statusCode >= 500 &&
routerContext.statusCode < 600 &&
// TODO: if loaderFailureMode is not 'errroBoundary', error log will not be printed.
loaderFailureMode === 'clientRender'
) {
routerContext.statusCode = 200;
throw (routerContext.errors as Error[])[0];
const errors = Object.values(
routerContext.errors as Record<string, Error>,
);
throw errors[0];
}

const router = createStaticRouter(routes, routerContext);
Expand Down

0 comments on commit e220a13

Please sign in to comment.