File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,8 +9,13 @@ type AppBootstrapProps = {
99 children : React . ReactNode ;
1010} ;
1111
12+ type BootstrapState =
13+ | { status : 'loading' }
14+ | { status : 'ready' }
15+ | { status : 'error' ; error : Error } ;
16+
1217export function AppBootstrap ( { children } : Readonly < AppBootstrapProps > ) {
13- const [ isReady , setIsReady ] = useState ( false ) ;
18+ const [ state , setState ] = useState < BootstrapState > ( { status : 'loading' } ) ;
1419
1520 useEffect ( ( ) => {
1621 let mounted = true ;
@@ -22,12 +27,18 @@ export function AppBootstrap({ children }: Readonly<AppBootstrapProps>) {
2227 await initializeInternal ( ) ;
2328
2429 if ( mounted ) {
25- setIsReady ( true ) ;
30+ setState ( { status : 'ready' } ) ;
2631 }
2732 } catch ( error ) {
2833 console . error ( 'Bootstrap failed:' , error ) ;
2934 if ( mounted ) {
30- setIsReady ( true ) ;
35+ setState ( {
36+ status : 'error' ,
37+ error :
38+ error instanceof Error
39+ ? error
40+ : new Error ( 'Failed to initialize application' ) ,
41+ } ) ;
3142 }
3243 }
3344 }
@@ -39,13 +50,17 @@ export function AppBootstrap({ children }: Readonly<AppBootstrapProps>) {
3950 } ;
4051 } , [ ] ) ;
4152
42- if ( ! isReady ) {
53+ if ( state . status === 'loading' ) {
4354 return (
4455 < div className = "flex h-screen w-screen items-center justify-center" >
4556 < LoadingSpinner size = { 50 } />
4657 </ div >
4758 ) ;
4859 }
4960
61+ if ( state . status === 'error' ) {
62+ throw state . error ;
63+ }
64+
5065 return children ;
5166}
Original file line number Diff line number Diff line change @@ -6,14 +6,17 @@ import './i18n';
66/* Make sure i18n module is imported before App component which uses translations*/
77import App from './app/app' ;
88import { AppBootstrap } from './app/app-bootstrap' ;
9+ import { OpsErrorBoundary } from './app/common/error-boundaries/ops-error-boundary' ;
910
1011const root = ReactDOM . createRoot (
1112 document . getElementById ( 'root' ) as HTMLElement ,
1213) ;
1314root . render (
1415 < StrictMode >
15- < AppBootstrap >
16- < App />
17- </ AppBootstrap >
16+ < OpsErrorBoundary >
17+ < AppBootstrap >
18+ < App />
19+ </ AppBootstrap >
20+ </ OpsErrorBoundary >
1821 </ StrictMode > ,
1922) ;
You can’t perform that action at this time.
0 commit comments