mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix(routing): give every lazy page its own ErrorBoundary
A render error in any route used to bubble all the way up to the single page-level boundary at AppWithNavigator, replacing the entire shell (sidebar, header, blocking overlays) with the contained error UI — even if only one sub-page was broken. Embed an ErrorBoundary inside LazyPage so the smallest meaningful unit (a route's lazy chunk + its rendered tree) is the boundary scope. Shell chrome stays alive, the user can navigate elsewhere, and chunk-load failures still get the lazyWithRetry reload path because the boundary sits outside Suspense.
This commit is contained in:
11
src/App.tsx
11
src/App.tsx
@@ -200,9 +200,16 @@ function AdminRoute({ children }: { children: React.ReactNode }) {
|
||||
return <Layout>{children}</Layout>;
|
||||
}
|
||||
|
||||
// Suspense wrapper for lazy components
|
||||
// Suspense + error boundary wrapper for lazy routes. The boundary lives
|
||||
// OUTSIDE Suspense so chunk-load failures (caught by lazyWithRetry's reload
|
||||
// path) and render-time exceptions both surface in the page-level fallback
|
||||
// instead of crashing the entire shell via the top-level boundary.
|
||||
function LazyPage({ children }: { children: React.ReactNode }) {
|
||||
return <Suspense fallback={<PageLoader variant="dark" />}>{children}</Suspense>;
|
||||
return (
|
||||
<ErrorBoundary level="page">
|
||||
<Suspense fallback={<PageLoader variant="dark" />}>{children}</Suspense>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
function BlockingOverlay() {
|
||||
|
||||
Reference in New Issue
Block a user