@@ -19,6 +19,7 @@ import {
19
19
HydrationUtilsPreRender ,
20
20
} from "~/useHydrated" ;
21
21
import settings from "./settings" ;
22
+ import { ReactNode } from "react" ;
22
23
23
24
export const links : LinksFunction = ( ) => [
24
25
...( cssBundleHref ? [ { rel : "stylesheet" , href : cssBundleHref } ] : [ ] ) ,
@@ -37,8 +38,29 @@ export async function loader() {
37
38
}
38
39
39
40
export default function App ( ) {
40
- useGlobalProgress ( ) ;
41
41
const data = useLoaderData < typeof loader > ( ) ;
42
+ return (
43
+ < Scaffold >
44
+ < div
45
+ id = "portal"
46
+ style = { { position : "fixed" , left : 0 , top : 0 , zIndex : 9999 } }
47
+ />
48
+ < script
49
+ // load client side env vars
50
+ dangerouslySetInnerHTML = { {
51
+ __html : `window.ENV = ${ JSON . stringify ( data . ENV ) } ;` ,
52
+ } }
53
+ />
54
+ < HydrationUtilsPreRender />
55
+ < Outlet />
56
+ < HydrationUtilsPostRender />
57
+ < ScrollRestoration />
58
+ </ Scaffold >
59
+ ) ;
60
+ }
61
+
62
+ function Scaffold ( { children } : { children ?: ReactNode } ) {
63
+ useGlobalProgress ( ) ;
42
64
43
65
return (
44
66
< html lang = "en" >
@@ -53,20 +75,7 @@ export default function App() {
53
75
> </ script >
54
76
</ head >
55
77
< body >
56
- < div
57
- id = "portal"
58
- style = { { position : "fixed" , left : 0 , top : 0 , zIndex : 9999 } }
59
- />
60
- < HydrationUtilsPreRender />
61
- < Outlet />
62
- < HydrationUtilsPostRender />
63
- < ScrollRestoration />
64
- < script
65
- // load client side env vars
66
- dangerouslySetInnerHTML = { {
67
- __html : `window.ENV = ${ JSON . stringify ( data . ENV ) } ;` ,
68
- } }
69
- />
78
+ { children }
70
79
< Scripts />
71
80
< LiveReload />
72
81
</ body >
@@ -81,18 +90,9 @@ const reloadOnErrors = [
81
90
"NetworkError" ,
82
91
] ;
83
92
84
- const ignoreErrors = [ "AbortError" ] ;
85
-
86
93
export function ErrorBoundary ( ) {
87
94
const error = useRouteError ( ) ;
88
95
89
- if (
90
- ignoreErrors . some ( ( msg ) =>
91
- `${ error } ` . toLowerCase ( ) . includes ( msg . toLowerCase ( ) )
92
- )
93
- ) {
94
- return < > </ > ;
95
- }
96
96
if (
97
97
reloadOnErrors . some ( ( msg ) =>
98
98
`${ error } ` . toLowerCase ( ) . includes ( msg . toLowerCase ( ) )
@@ -106,18 +106,18 @@ export function ErrorBoundary() {
106
106
// when true, this is what used to go to `CatchBoundary`
107
107
if ( isRouteErrorResponse ( error ) ) {
108
108
return (
109
- < div >
109
+ < Scaffold >
110
110
< p > Status: { error . status } </ p >
111
111
< pre > { JSON . stringify ( error . data ) } </ pre >
112
- </ div >
112
+ </ Scaffold >
113
113
) ;
114
114
}
115
115
116
116
return (
117
- < div >
117
+ < Scaffold >
118
118
< h1 > Uh oh ...</ h1 >
119
119
< p > Something went wrong.</ p >
120
120
< pre > { `${ error } ` } </ pre >
121
- </ div >
121
+ </ Scaffold >
122
122
) ;
123
123
}
0 commit comments