@@ -75,30 +75,23 @@ class ErrorBoundary extends React.Component<
75
75
}
76
76
77
77
state = initialState
78
- updatedWithError = false
79
78
resetErrorBoundary = ( ...args : Array < unknown > ) => {
80
79
this . props . onReset ?.( ...args )
81
80
this . reset ( )
82
81
}
83
82
84
83
reset ( ) {
85
- this . updatedWithError = false
86
84
this . setState ( initialState )
87
85
}
88
86
89
87
componentDidCatch ( error : Error , info : React . ErrorInfo ) {
90
88
this . props . onError ?.( error , info )
91
89
}
92
90
93
- componentDidMount ( ) {
94
- const { error} = this . state
95
-
96
- if ( error !== null ) {
97
- this . updatedWithError = true
98
- }
99
- }
100
-
101
- componentDidUpdate ( prevProps : ErrorBoundaryProps ) {
91
+ componentDidUpdate (
92
+ prevProps : ErrorBoundaryProps ,
93
+ prevState : ErrorBoundaryState ,
94
+ ) {
102
95
const { error} = this . state
103
96
const { resetKeys} = this . props
104
97
@@ -108,12 +101,12 @@ class ErrorBoundary extends React.Component<
108
101
// error to be thrown.
109
102
// So we make sure that we don't check the resetKeys on the first call
110
103
// of cDU after the error is set
111
- if ( error !== null && ! this . updatedWithError ) {
112
- this . updatedWithError = true
113
- return
114
- }
115
104
116
- if ( error !== null && changedArray ( prevProps . resetKeys , resetKeys ) ) {
105
+ if (
106
+ error !== null &&
107
+ prevState . error !== null &&
108
+ changedArray ( prevProps . resetKeys , resetKeys )
109
+ ) {
117
110
this . props . onResetKeysChange ?.( prevProps . resetKeys , resetKeys )
118
111
this . reset ( )
119
112
}
@@ -183,6 +176,7 @@ export type {
183
176
184
177
/*
185
178
eslint
179
+ @typescript -eslint/sort-type-union-intersection-members: "off",
186
180
@typescript -eslint/no-throw-literal: "off",
187
181
@typescript -eslint/prefer-nullish-coalescing: "off"
188
182
*/
0 commit comments