@@ -38,7 +38,7 @@ describe('ReactIncrementalErrorHandling', () => {
38
38
it ( 'catches render error in a boundary during full deferred mounting' , ( ) => {
39
39
class ErrorBoundary extends React . Component {
40
40
state = { error : null } ;
41
- unstable_handleError ( error ) {
41
+ componentDidCatch ( error ) {
42
42
this . setState ( { error} ) ;
43
43
}
44
44
render ( ) {
@@ -68,8 +68,8 @@ describe('ReactIncrementalErrorHandling', () => {
68
68
var ops = [ ] ;
69
69
class ErrorBoundary extends React . Component {
70
70
state = { error : null } ;
71
- unstable_handleError ( error ) {
72
- ops . push ( 'ErrorBoundary unstable_handleError ' ) ;
71
+ componentDidCatch ( error ) {
72
+ ops . push ( 'ErrorBoundary componentDidCatch ' ) ;
73
73
this . setState ( { error} ) ;
74
74
}
75
75
render ( ) {
@@ -103,7 +103,7 @@ describe('ReactIncrementalErrorHandling', () => {
103
103
ReactNoop . flushDeferredPri ( 30 ) ;
104
104
expect ( ops ) . toEqual ( [
105
105
'BrokenRender' ,
106
- 'ErrorBoundary unstable_handleError ' ,
106
+ 'ErrorBoundary componentDidCatch ' ,
107
107
'ErrorBoundary render error' ,
108
108
] ) ;
109
109
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Caught an error: Hello.' ) ] ) ;
@@ -113,8 +113,8 @@ describe('ReactIncrementalErrorHandling', () => {
113
113
var ops = [ ] ;
114
114
class ErrorBoundary extends React . Component {
115
115
state = { error : null } ;
116
- unstable_handleError ( error ) {
117
- ops . push ( 'ErrorBoundary unstable_handleError ' ) ;
116
+ componentDidCatch ( error ) {
117
+ ops . push ( 'ErrorBoundary componentDidCatch ' ) ;
118
118
this . setState ( { error} ) ;
119
119
}
120
120
render ( ) {
@@ -145,7 +145,7 @@ describe('ReactIncrementalErrorHandling', () => {
145
145
expect ( ops ) . toEqual ( [
146
146
'ErrorBoundary render success' ,
147
147
'BrokenRender' ,
148
- 'ErrorBoundary unstable_handleError ' ,
148
+ 'ErrorBoundary componentDidCatch ' ,
149
149
'ErrorBoundary render error' ,
150
150
] ) ;
151
151
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Caught an error: Hello.' ) ] ) ;
@@ -155,8 +155,8 @@ describe('ReactIncrementalErrorHandling', () => {
155
155
var ops = [ ] ;
156
156
class ErrorBoundary extends React . Component {
157
157
state = { error : null } ;
158
- unstable_handleError ( error ) {
159
- ops . push ( 'ErrorBoundary unstable_handleError ' ) ;
158
+ componentDidCatch ( error ) {
159
+ ops . push ( 'ErrorBoundary componentDidCatch ' ) ;
160
160
this . setState ( { error} ) ;
161
161
}
162
162
render ( ) {
@@ -194,7 +194,7 @@ describe('ReactIncrementalErrorHandling', () => {
194
194
expect ( ops ) . toEqual ( [
195
195
'ErrorBoundary render success' ,
196
196
'BrokenRender' ,
197
- 'ErrorBoundary unstable_handleError ' ,
197
+ 'ErrorBoundary componentDidCatch ' ,
198
198
'ErrorBoundary render error' ,
199
199
] ) ;
200
200
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Caught an error: Hello.' ) ] ) ;
@@ -203,8 +203,8 @@ describe('ReactIncrementalErrorHandling', () => {
203
203
it ( 'propagates an error from a noop error boundary during full deferred mounting' , ( ) => {
204
204
var ops = [ ] ;
205
205
class RethrowErrorBoundary extends React . Component {
206
- unstable_handleError ( error ) {
207
- ops . push ( 'RethrowErrorBoundary unstable_handleError ' ) ;
206
+ componentDidCatch ( error ) {
207
+ ops . push ( 'RethrowErrorBoundary componentDidCatch ' ) ;
208
208
throw error ;
209
209
}
210
210
render ( ) {
@@ -230,16 +230,16 @@ describe('ReactIncrementalErrorHandling', () => {
230
230
expect ( ops ) . toEqual ( [
231
231
'RethrowErrorBoundary render' ,
232
232
'BrokenRender' ,
233
- 'RethrowErrorBoundary unstable_handleError ' ,
233
+ 'RethrowErrorBoundary componentDidCatch ' ,
234
234
] ) ;
235
235
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
236
236
} ) ;
237
237
238
238
it ( 'propagates an error from a noop error boundary during partial deferred mounting' , ( ) => {
239
239
var ops = [ ] ;
240
240
class RethrowErrorBoundary extends React . Component {
241
- unstable_handleError ( error ) {
242
- ops . push ( 'RethrowErrorBoundary unstable_handleError ' ) ;
241
+ componentDidCatch ( error ) {
242
+ ops . push ( 'RethrowErrorBoundary componentDidCatch ' ) ;
243
243
throw error ;
244
244
}
245
245
render ( ) {
@@ -268,16 +268,16 @@ describe('ReactIncrementalErrorHandling', () => {
268
268
} ) . toThrow ( 'Hello' ) ;
269
269
expect ( ops ) . toEqual ( [
270
270
'BrokenRender' ,
271
- 'RethrowErrorBoundary unstable_handleError ' ,
271
+ 'RethrowErrorBoundary componentDidCatch ' ,
272
272
] ) ;
273
273
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
274
274
} ) ;
275
275
276
276
it ( 'propagates an error from a noop error boundary during synchronous mounting' , ( ) => {
277
277
var ops = [ ] ;
278
278
class RethrowErrorBoundary extends React . Component {
279
- unstable_handleError ( error ) {
280
- ops . push ( 'RethrowErrorBoundary unstable_handleError ' ) ;
279
+ componentDidCatch ( error ) {
280
+ ops . push ( 'RethrowErrorBoundary componentDidCatch ' ) ;
281
281
throw error ;
282
282
}
283
283
render ( ) {
@@ -303,16 +303,16 @@ describe('ReactIncrementalErrorHandling', () => {
303
303
expect ( ops ) . toEqual ( [
304
304
'RethrowErrorBoundary render' ,
305
305
'BrokenRender' ,
306
- 'RethrowErrorBoundary unstable_handleError ' ,
306
+ 'RethrowErrorBoundary componentDidCatch ' ,
307
307
] ) ;
308
308
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
309
309
} ) ;
310
310
311
311
it ( 'propagates an error from a noop error boundary during batched mounting' , ( ) => {
312
312
var ops = [ ] ;
313
313
class RethrowErrorBoundary extends React . Component {
314
- unstable_handleError ( error ) {
315
- ops . push ( 'RethrowErrorBoundary unstable_handleError ' ) ;
314
+ componentDidCatch ( error ) {
315
+ ops . push ( 'RethrowErrorBoundary componentDidCatch ' ) ;
316
316
throw error ;
317
317
}
318
318
render ( ) {
@@ -345,7 +345,7 @@ describe('ReactIncrementalErrorHandling', () => {
345
345
expect ( ops ) . toEqual ( [
346
346
'RethrowErrorBoundary render' ,
347
347
'BrokenRender' ,
348
- 'RethrowErrorBoundary unstable_handleError ' ,
348
+ 'RethrowErrorBoundary componentDidCatch ' ,
349
349
] ) ;
350
350
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
351
351
} ) ;
@@ -485,7 +485,7 @@ describe('ReactIncrementalErrorHandling', () => {
485
485
it ( 'continues work on other roots despite caught errors' , ( ) => {
486
486
class ErrorBoundary extends React . Component {
487
487
state = { error : null } ;
488
- unstable_handleError ( error ) {
488
+ componentDidCatch ( error ) {
489
489
this . setState ( { error} ) ;
490
490
}
491
491
render ( ) {
@@ -627,7 +627,7 @@ describe('ReactIncrementalErrorHandling', () => {
627
627
628
628
class Boundary extends React . Component {
629
629
state = { error : null } ;
630
- unstable_handleError ( error ) {
630
+ componentDidCatch ( error ) {
631
631
this . setState ( { error} ) ;
632
632
}
633
633
render ( ) {
@@ -662,7 +662,7 @@ describe('ReactIncrementalErrorHandling', () => {
662
662
663
663
class ErrorBoundary extends React . Component {
664
664
state = { error : null } ;
665
- unstable_handleError ( error ) {
665
+ componentDidCatch ( error ) {
666
666
this . setState ( { error} ) ;
667
667
}
668
668
render ( ) {
@@ -699,7 +699,7 @@ describe('ReactIncrementalErrorHandling', () => {
699
699
700
700
class ErrorBoundary extends React . Component {
701
701
state = { error : null } ;
702
- unstable_handleError ( error ) {
702
+ componentDidCatch ( error ) {
703
703
this . setState ( { error} ) ;
704
704
}
705
705
render ( ) {
@@ -1002,7 +1002,7 @@ describe('ReactIncrementalErrorHandling', () => {
1002
1002
let renderAttempts = 0 ;
1003
1003
1004
1004
class ErrorBoundaryComponent extends React . Component {
1005
- unstable_handleError ( error ) {
1005
+ componentDidCatch ( error ) {
1006
1006
handleErrorCalls . push ( error ) ;
1007
1007
this . setState ( { } ) ; // Render again
1008
1008
}
0 commit comments