File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,12 @@ type State = {
18
18
info : ?ErrorInfo ,
19
19
} ;
20
20
21
- class ErrorBoundary extends Component {
21
+ class ErrorBoundary extends Component < Props , State > {
22
22
props : Props ;
23
23
state : State ;
24
24
25
+ setState : Function
26
+
25
27
static defaultProps = {
26
28
FallbackComponent : ErrorBoundaryFallbackComponent ,
27
29
} ;
@@ -61,4 +63,16 @@ class ErrorBoundary extends Component {
61
63
}
62
64
}
63
65
66
+
67
+ export const withErrorBoundary : Function = (
68
+ Component : Class < React . Component < * >> ,
69
+ FallbackComponent : Class < React . Component < * >> ,
70
+ onError : Function
71
+ ) : Function => props => (
72
+ < ErrorBoundary FallbackComponent = { FallbackComponent } onError = { onError } >
73
+ < Component { ...props } />
74
+ </ ErrorBoundary >
75
+ ) ;
76
+
77
+
64
78
export default ErrorBoundary ;
Original file line number Diff line number Diff line change 1
1
/** @flow */
2
2
3
3
import ErrorBoundaryFallbackComponent from './ErrorBoundaryFallbackComponent' ;
4
- import ErrorBoundary from './ErrorBoundary' ;
4
+ import ErrorBoundary , { withErrorBoundary } from './ErrorBoundary' ;
5
5
6
6
export default ErrorBoundary ;
7
- export { ErrorBoundary , ErrorBoundaryFallbackComponent } ;
7
+ export { ErrorBoundary , withErrorBoundary , ErrorBoundaryFallbackComponent } ;
You can’t perform that action at this time.
0 commit comments