@@ -75,30 +75,23 @@ class ErrorBoundary extends React.Component<
7575 }
7676
7777 state = initialState
78- updatedWithError = false
7978 resetErrorBoundary = ( ...args : Array < unknown > ) => {
8079 this . props . onReset ?.( ...args )
8180 this . reset ( )
8281 }
8382
8483 reset ( ) {
85- this . updatedWithError = false
8684 this . setState ( initialState )
8785 }
8886
8987 componentDidCatch ( error : Error , info : React . ErrorInfo ) {
9088 this . props . onError ?.( error , info )
9189 }
9290
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+ ) {
10295 const { error} = this . state
10396 const { resetKeys} = this . props
10497
@@ -108,12 +101,12 @@ class ErrorBoundary extends React.Component<
108101 // error to be thrown.
109102 // So we make sure that we don't check the resetKeys on the first call
110103 // of cDU after the error is set
111- if ( error !== null && ! this . updatedWithError ) {
112- this . updatedWithError = true
113- return
114- }
115104
116- if ( error !== null && changedArray ( prevProps . resetKeys , resetKeys ) ) {
105+ if (
106+ error !== null &&
107+ prevState . error !== null &&
108+ changedArray ( prevProps . resetKeys , resetKeys )
109+ ) {
117110 this . props . onResetKeysChange ?.( prevProps . resetKeys , resetKeys )
118111 this . reset ( )
119112 }
@@ -183,6 +176,7 @@ export type {
183176
184177/*
185178eslint
179+ @typescript -eslint/sort-type-union-intersection-members: "off",
186180 @typescript -eslint/no-throw-literal: "off",
187181 @typescript -eslint/prefer-nullish-coalescing: "off"
188182*/
0 commit comments