@@ -79,7 +79,7 @@ class LayoutWithoutTheme extends Component<
79
79
LayoutWithoutThemeProps ,
80
80
LayoutState
81
81
> {
82
- state = { hasError : false , errorMessage : null , errorInfo : null } ;
82
+ state : LayoutState = { hasError : false , error : null , errorInfo : null } ;
83
83
84
84
constructor ( props ) {
85
85
super ( props ) ;
@@ -95,8 +95,8 @@ class LayoutWithoutTheme extends Component<
95
95
} ) ;
96
96
}
97
97
98
- componentDidCatch ( errorMessage , errorInfo ) {
99
- this . setState ( { hasError : true , errorMessage , errorInfo } ) ;
98
+ componentDidCatch ( error : Error , errorInfo : ErrorInfo ) {
99
+ this . setState ( { hasError : true , error , errorInfo } ) ;
100
100
}
101
101
102
102
render ( ) {
@@ -105,7 +105,7 @@ class LayoutWithoutTheme extends Component<
105
105
children,
106
106
classes,
107
107
className,
108
- error,
108
+ error : ErrorComponent ,
109
109
dashboard,
110
110
logout,
111
111
menu,
@@ -120,7 +120,7 @@ class LayoutWithoutTheme extends Component<
120
120
staticContext,
121
121
...props
122
122
} = this . props ;
123
- const { hasError, errorMessage , errorInfo } = this . state ;
123
+ const { hasError, error , errorInfo } = this . state ;
124
124
return (
125
125
< >
126
126
< div
@@ -138,13 +138,15 @@ class LayoutWithoutTheme extends Component<
138
138
} ) ,
139
139
} ) }
140
140
< div id = "main-content" className = { classes . content } >
141
- { hasError
142
- ? createElement ( error , {
143
- error : errorMessage ,
144
- errorInfo,
145
- title,
146
- } )
147
- : children }
141
+ { hasError ? (
142
+ < ErrorComponent
143
+ error = { error }
144
+ errorInfo = { errorInfo }
145
+ title = { title }
146
+ />
147
+ ) : (
148
+ children
149
+ ) }
148
150
</ div >
149
151
</ main >
150
152
</ div >
@@ -186,8 +188,8 @@ export interface LayoutProps
186
188
classes ?: any ;
187
189
className ?: string ;
188
190
error ?: ComponentType < {
189
- error ?: string ;
190
- errorInfo ?: React . ErrorInfo ;
191
+ error ?: Error ;
192
+ errorInfo ?: ErrorInfo ;
191
193
title ?: string | ReactElement < any > ;
192
194
} > ;
193
195
menu ?: ComponentType < MenuProps > ;
@@ -198,8 +200,8 @@ export interface LayoutProps
198
200
199
201
export interface LayoutState {
200
202
hasError : boolean ;
201
- errorMessage : string ;
202
- errorInfo : ErrorInfo ;
203
+ error ?: Error ;
204
+ errorInfo ? : ErrorInfo ;
203
205
}
204
206
205
207
interface LayoutWithoutThemeProps
0 commit comments