File tree Expand file tree Collapse file tree 3 files changed +68
-11
lines changed
Expand file tree Collapse file tree 3 files changed +68
-11
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ interface ErrorBoundaryState {
4+ hasError : boolean ;
5+ error ?: Error ;
6+ }
7+
8+ export class ErrorBoundary extends React . Component <
9+ React . PropsWithChildren < object > ,
10+ ErrorBoundaryState
11+ > {
12+ constructor ( props : React . PropsWithChildren < object > ) {
13+ super ( props ) ;
14+ this . state = { hasError : false } ;
15+ }
16+
17+ static getDerivedStateFromError ( error : Error ) : ErrorBoundaryState {
18+ console . error ( 'ErrorBoundary: Caught error:' , error ) ;
19+ return { hasError : true , error } ;
20+ }
21+
22+ componentDidCatch ( error : Error , errorInfo : React . ErrorInfo ) {
23+ console . error ( 'ErrorBoundary: Error details:' , {
24+ error : error . message ,
25+ stack : error . stack ,
26+ componentStack : errorInfo . componentStack
27+ } ) ;
28+ }
29+
30+ render ( ) {
31+ if ( this . state . hasError ) {
32+ return (
33+ < div style = { { padding : '20px' , color : 'red' } } >
34+ < h1 > Something went wrong.</ h1 >
35+ < pre > { this . state . error ?. message } </ pre >
36+ < pre > { this . state . error ?. stack } </ pre >
37+ </ div >
38+ ) ;
39+ }
40+
41+ return this . props . children ;
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ export function SimpleFallback ( ) {
2+ console . log ( 'SimpleFallback: Rendering fallback component' ) ;
3+
4+ return (
5+ < div style = { {
6+ padding : '20px' ,
7+ backgroundColor : 'white' ,
8+ color : 'black' ,
9+ minHeight : '100vh' ,
10+ display : 'flex' ,
11+ flexDirection : 'column' ,
12+ alignItems : 'center' ,
13+ justifyContent : 'center'
14+ } } >
15+ < h1 > Simple Fallback Component</ h1 >
16+ < p > This is a test component to see if basic rendering works.</ p >
17+ < p > If you can see this, the app can render basic content.</ p >
18+ </ div >
19+ ) ;
20+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import { Toaster } from './components/ui/toaster.tsx';
1313import './index.css' ;
1414import { router } from './router.tsx' ;
1515import { wagmiAdapter } from './utils/wagmiConfig.ts' ;
16+ import { ErrorBoundary } from './components/ErrorBoundary.tsx' ;
17+ import { SimpleFallback } from './components/SimpleFallback.tsx' ;
1618
1719console . log ( 'Starting app initialization...' ) ;
1820
3638
3739 ReactDOM . createRoot ( rootElement ) . render (
3840 < React . StrictMode >
39- < WagmiProvider config = { wagmiAdapter . wagmiConfig } >
40- < QueryClientProvider client = { queryClient } >
41- < ConditionalRollbarWrapper
42- rollbar = { rollbar }
43- rollbarConfig = { rollbarConfig }
44- >
45- < RouterProvider router = { router } />
46- </ ConditionalRollbarWrapper >
47- </ QueryClientProvider >
48- </ WagmiProvider >
49- < Toaster />
41+ < ErrorBoundary >
42+ < SimpleFallback />
43+ </ ErrorBoundary >
5044 </ React . StrictMode >
5145 ) ;
5246 console . log ( 'App rendered successfully' ) ;
You can’t perform that action at this time.
0 commit comments