Skip to content

Commit 590a108

Browse files
authored
fix: wrap app in global ErrorBoundary to prevent blank-screen crash (#7872) - Added src/components/ErrorBoundary.tsx - Wrapped <Component /> in _app.tsx with <ErrorBoundary> - Prevents complete UI loss on runtime errors - Logs error in console, shows friendly message to users Closes #7872
1 parent 8d28ee2 commit 590a108

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pages/_app.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*/
4+
import { ErrorBoundary } from '../components/ErrorBoundary';
45

56
import {useEffect} from 'react';
67
import {AppProps} from 'next/app';
@@ -54,5 +55,7 @@ export default function MyApp({Component, pageProps}: AppProps) {
5455
};
5556
}, [router.events]);
5657

57-
return <Component {...pageProps} />;
58+
return <ErrorBoundary>
59+
<Component {...pageProps} />
60+
</ErrorBoundary>;
5861
}

0 commit comments

Comments
 (0)