7
7
useMemo ,
8
8
useState ,
9
9
} from "react" ;
10
- import { Links , LiveReload , Scripts , ScrollRestoration } from "remix" ;
10
+ import { Links , LiveReload , Meta , Scripts , ScrollRestoration } from "remix" ;
11
11
import codeStyles from "highlight.js/styles/github-dark.css" ;
12
12
// @ts -ignore
13
13
import styleInject from "style-inject" ;
@@ -140,6 +140,54 @@ export const useError = () => {
140
140
export function ErrorBoundary ( { error } : { error : Error } ) {
141
141
console . error ( error ) ;
142
142
143
+ if ( process . env . NODE_ENV !== "development" ) {
144
+ return < ProdErrorBoundary error = { error } /> ;
145
+ }
146
+
147
+ return < DevErrorBoundary error = { error } /> ;
148
+ }
149
+
150
+ export function ProdErrorBoundary ( { error } : { error : Error } ) {
151
+ return (
152
+ < html lang = "en" >
153
+ < head >
154
+ < meta charSet = "utf-8" />
155
+ < meta name = "viewport" content = "width=device-width,initial-scale=1" />
156
+ < Meta />
157
+ < Links />
158
+ </ head >
159
+
160
+ < body >
161
+ < main
162
+ style = { {
163
+ display : "flex" ,
164
+ justifyContent : "center" ,
165
+ alignItems : "center" ,
166
+ width : "100vw" ,
167
+ height : "100vh" ,
168
+ gap : "1rem" ,
169
+ } }
170
+ >
171
+ < h1 > 500</ h1 >
172
+ < span
173
+ style = { {
174
+ height : "2.5rem" ,
175
+ width : "2px" ,
176
+ backgroundColor : "rgb(75, 85, 99)" ,
177
+ } }
178
+ />
179
+ < span > Internal Server Error.</ span >
180
+ </ main >
181
+
182
+ < ScrollRestoration />
183
+
184
+ < Scripts />
185
+ </ body >
186
+ </ html >
187
+ ) ;
188
+ }
189
+
190
+ export function DevErrorBoundary ( { error } : { error : Error } ) {
143
191
useLayoutEffect ( ( ) => {
144
192
styleInject ( styles ) ;
145
193
styleInject ( codeStyles ) ;
@@ -160,7 +208,6 @@ export function ErrorBoundary({ error }: { error: Error }) {
160
208
< title > { `💥 ${ type } : ${ message } ` } </ title >
161
209
< meta charSet = "utf-8" />
162
210
< meta name = "viewport" content = "width=device-width,initial-scale=1" />
163
- { /* <link rel="stylesheet" href={codeStyles} /> */ }
164
211
< link rel = "preconnect" href = "https://fonts.googleapis.com" />
165
212
< link
166
213
rel = "preconnect"
@@ -171,7 +218,6 @@ export function ErrorBoundary({ error }: { error: Error }) {
171
218
href = "https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900& display = swap "
172
219
rel = "stylesheet"
173
220
/>
174
- < Links />
175
221
</ head >
176
222
177
223
< body
0 commit comments