Skip to content

Commit b27d3a3

Browse files
committed
Replaced "unstable_handleError" with "componentDidError"
Ran new codemod to rename all identifiers. Searched-and-replaced strings occurrences.
1 parent 3b5e3b5 commit b27d3a3

File tree

9 files changed

+101
-101
lines changed

9 files changed

+101
-101
lines changed

src/renderers/__tests__/ReactErrorBoundaries-test.js

Lines changed: 61 additions & 61 deletions
Large diffs are not rendered by default.

src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ describe('ReactDOMFiber', () => {
619619

620620
class ErrorBoundary extends React.Component {
621621
state = {error: null};
622-
unstable_handleError(error) {
622+
componentDidCatch(error) {
623623
this.setState({error});
624624
}
625625
render() {
@@ -652,7 +652,7 @@ describe('ReactDOMFiber', () => {
652652

653653
class ErrorBoundary extends React.Component {
654654
state = {error: null};
655-
unstable_handleError(error) {
655+
componentDidCatch(error) {
656656
this.setState({error});
657657
}
658658
render() {

src/renderers/shared/fiber/ReactFiberErrorLogger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function logCapturedError(capturedError: CapturedError): void {
7474
`Recreating the tree from scratch failed so React will unmount the tree.`;
7575
}
7676
} else {
77-
// TODO Link to unstable_handleError() documentation once it exists.
77+
// TODO Link to componentDidCatch() documentation once it exists.
7878
errorBoundaryMessage =
7979
'Consider adding an error boundary to your tree to customize error handling behavior.';
8080
}

src/renderers/shared/fiber/ReactFiberScheduler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
216216
let isCallbackScheduled: boolean = false;
217217

218218
// Keep track of which fibers have captured an error that need to be handled.
219-
// Work is removed from this collection after unstable_handleError is called.
219+
// Work is removed from this collection after componentDidCatch is called.
220220
let capturedErrors: Map<Fiber, CapturedError> | null = null;
221221
// Keep track of which fibers have failed during the current batch of work.
222222
// This is a different set than capturedErrors, because it is not reset until
@@ -1054,7 +1054,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
10541054
while (node !== null && boundary === null) {
10551055
if (node.tag === ClassComponent) {
10561056
const instance = node.stateNode;
1057-
if (typeof instance.unstable_handleError === 'function') {
1057+
if (typeof instance.componentDidCatch === 'function') {
10581058
errorBoundaryFound = true;
10591059
errorBoundaryName = getComponentName(node);
10601060

@@ -1210,7 +1210,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
12101210

12111211
// Allow the boundary to handle the error, usually by scheduling
12121212
// an update to itself
1213-
instance.unstable_handleError(error, info);
1213+
instance.componentDidCatch(error, info);
12141214
return;
12151215
case HostRoot:
12161216
if (firstUncaughtError === null) {

src/renderers/shared/fiber/__tests__/ReactIncremental-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ describe('ReactIncremental', () => {
22572257

22582258
it('maintains the correct context when unwinding due to an error in render', () => {
22592259
class Root extends React.Component {
2260-
unstable_handleError(error) {
2260+
componentDidCatch(error) {
22612261
// If context is pushed/popped correctly,
22622262
// This method will be used to handle the intentionally-thrown Error.
22632263
}

src/renderers/shared/fiber/__tests__/ReactIncrementalErrorHandling-test.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('ReactIncrementalErrorHandling', () => {
3838
it('catches render error in a boundary during full deferred mounting', () => {
3939
class ErrorBoundary extends React.Component {
4040
state = {error: null};
41-
unstable_handleError(error) {
41+
componentDidCatch(error) {
4242
this.setState({error});
4343
}
4444
render() {
@@ -68,8 +68,8 @@ describe('ReactIncrementalErrorHandling', () => {
6868
var ops = [];
6969
class ErrorBoundary extends React.Component {
7070
state = {error: null};
71-
unstable_handleError(error) {
72-
ops.push('ErrorBoundary unstable_handleError');
71+
componentDidCatch(error) {
72+
ops.push('ErrorBoundary componentDidCatch');
7373
this.setState({error});
7474
}
7575
render() {
@@ -103,7 +103,7 @@ describe('ReactIncrementalErrorHandling', () => {
103103
ReactNoop.flushDeferredPri(30);
104104
expect(ops).toEqual([
105105
'BrokenRender',
106-
'ErrorBoundary unstable_handleError',
106+
'ErrorBoundary componentDidCatch',
107107
'ErrorBoundary render error',
108108
]);
109109
expect(ReactNoop.getChildren()).toEqual([span('Caught an error: Hello.')]);
@@ -113,8 +113,8 @@ describe('ReactIncrementalErrorHandling', () => {
113113
var ops = [];
114114
class ErrorBoundary extends React.Component {
115115
state = {error: null};
116-
unstable_handleError(error) {
117-
ops.push('ErrorBoundary unstable_handleError');
116+
componentDidCatch(error) {
117+
ops.push('ErrorBoundary componentDidCatch');
118118
this.setState({error});
119119
}
120120
render() {
@@ -145,7 +145,7 @@ describe('ReactIncrementalErrorHandling', () => {
145145
expect(ops).toEqual([
146146
'ErrorBoundary render success',
147147
'BrokenRender',
148-
'ErrorBoundary unstable_handleError',
148+
'ErrorBoundary componentDidCatch',
149149
'ErrorBoundary render error',
150150
]);
151151
expect(ReactNoop.getChildren()).toEqual([span('Caught an error: Hello.')]);
@@ -155,8 +155,8 @@ describe('ReactIncrementalErrorHandling', () => {
155155
var ops = [];
156156
class ErrorBoundary extends React.Component {
157157
state = {error: null};
158-
unstable_handleError(error) {
159-
ops.push('ErrorBoundary unstable_handleError');
158+
componentDidCatch(error) {
159+
ops.push('ErrorBoundary componentDidCatch');
160160
this.setState({error});
161161
}
162162
render() {
@@ -194,7 +194,7 @@ describe('ReactIncrementalErrorHandling', () => {
194194
expect(ops).toEqual([
195195
'ErrorBoundary render success',
196196
'BrokenRender',
197-
'ErrorBoundary unstable_handleError',
197+
'ErrorBoundary componentDidCatch',
198198
'ErrorBoundary render error',
199199
]);
200200
expect(ReactNoop.getChildren()).toEqual([span('Caught an error: Hello.')]);
@@ -203,8 +203,8 @@ describe('ReactIncrementalErrorHandling', () => {
203203
it('propagates an error from a noop error boundary during full deferred mounting', () => {
204204
var ops = [];
205205
class RethrowErrorBoundary extends React.Component {
206-
unstable_handleError(error) {
207-
ops.push('RethrowErrorBoundary unstable_handleError');
206+
componentDidCatch(error) {
207+
ops.push('RethrowErrorBoundary componentDidCatch');
208208
throw error;
209209
}
210210
render() {
@@ -230,16 +230,16 @@ describe('ReactIncrementalErrorHandling', () => {
230230
expect(ops).toEqual([
231231
'RethrowErrorBoundary render',
232232
'BrokenRender',
233-
'RethrowErrorBoundary unstable_handleError',
233+
'RethrowErrorBoundary componentDidCatch',
234234
]);
235235
expect(ReactNoop.getChildren()).toEqual([]);
236236
});
237237

238238
it('propagates an error from a noop error boundary during partial deferred mounting', () => {
239239
var ops = [];
240240
class RethrowErrorBoundary extends React.Component {
241-
unstable_handleError(error) {
242-
ops.push('RethrowErrorBoundary unstable_handleError');
241+
componentDidCatch(error) {
242+
ops.push('RethrowErrorBoundary componentDidCatch');
243243
throw error;
244244
}
245245
render() {
@@ -268,16 +268,16 @@ describe('ReactIncrementalErrorHandling', () => {
268268
}).toThrow('Hello');
269269
expect(ops).toEqual([
270270
'BrokenRender',
271-
'RethrowErrorBoundary unstable_handleError',
271+
'RethrowErrorBoundary componentDidCatch',
272272
]);
273273
expect(ReactNoop.getChildren()).toEqual([]);
274274
});
275275

276276
it('propagates an error from a noop error boundary during synchronous mounting', () => {
277277
var ops = [];
278278
class RethrowErrorBoundary extends React.Component {
279-
unstable_handleError(error) {
280-
ops.push('RethrowErrorBoundary unstable_handleError');
279+
componentDidCatch(error) {
280+
ops.push('RethrowErrorBoundary componentDidCatch');
281281
throw error;
282282
}
283283
render() {
@@ -303,16 +303,16 @@ describe('ReactIncrementalErrorHandling', () => {
303303
expect(ops).toEqual([
304304
'RethrowErrorBoundary render',
305305
'BrokenRender',
306-
'RethrowErrorBoundary unstable_handleError',
306+
'RethrowErrorBoundary componentDidCatch',
307307
]);
308308
expect(ReactNoop.getChildren()).toEqual([]);
309309
});
310310

311311
it('propagates an error from a noop error boundary during batched mounting', () => {
312312
var ops = [];
313313
class RethrowErrorBoundary extends React.Component {
314-
unstable_handleError(error) {
315-
ops.push('RethrowErrorBoundary unstable_handleError');
314+
componentDidCatch(error) {
315+
ops.push('RethrowErrorBoundary componentDidCatch');
316316
throw error;
317317
}
318318
render() {
@@ -345,7 +345,7 @@ describe('ReactIncrementalErrorHandling', () => {
345345
expect(ops).toEqual([
346346
'RethrowErrorBoundary render',
347347
'BrokenRender',
348-
'RethrowErrorBoundary unstable_handleError',
348+
'RethrowErrorBoundary componentDidCatch',
349349
]);
350350
expect(ReactNoop.getChildren()).toEqual([]);
351351
});
@@ -485,7 +485,7 @@ describe('ReactIncrementalErrorHandling', () => {
485485
it('continues work on other roots despite caught errors', () => {
486486
class ErrorBoundary extends React.Component {
487487
state = {error: null};
488-
unstable_handleError(error) {
488+
componentDidCatch(error) {
489489
this.setState({error});
490490
}
491491
render() {
@@ -627,7 +627,7 @@ describe('ReactIncrementalErrorHandling', () => {
627627

628628
class Boundary extends React.Component {
629629
state = {error: null};
630-
unstable_handleError(error) {
630+
componentDidCatch(error) {
631631
this.setState({error});
632632
}
633633
render() {
@@ -662,7 +662,7 @@ describe('ReactIncrementalErrorHandling', () => {
662662

663663
class ErrorBoundary extends React.Component {
664664
state = {error: null};
665-
unstable_handleError(error) {
665+
componentDidCatch(error) {
666666
this.setState({error});
667667
}
668668
render() {
@@ -699,7 +699,7 @@ describe('ReactIncrementalErrorHandling', () => {
699699

700700
class ErrorBoundary extends React.Component {
701701
state = {error: null};
702-
unstable_handleError(error) {
702+
componentDidCatch(error) {
703703
this.setState({error});
704704
}
705705
render() {
@@ -1002,7 +1002,7 @@ describe('ReactIncrementalErrorHandling', () => {
10021002
let renderAttempts = 0;
10031003

10041004
class ErrorBoundaryComponent extends React.Component {
1005-
unstable_handleError(error) {
1005+
componentDidCatch(error) {
10061006
handleErrorCalls.push(error);
10071007
this.setState({}); // Render again
10081008
}

src/renderers/shared/fiber/__tests__/ReactIncrementalPerf-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ describe('ReactDebugFiberPerf', () => {
357357

358358
class Boundary extends React.Component {
359359
state = {error: null};
360-
unstable_handleError(error) {
360+
componentDidCatch(error) {
361361
this.setState({error});
362362
}
363363
render() {

src/renderers/shared/stack/reconciler/ReactCompositeComponent.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ var ReactCompositeComponent = {
352352
}
353353

354354
var markup;
355-
if (inst.unstable_handleError) {
355+
if (inst.componentDidCatch) {
356356
markup = this.performInitialMountWithErrorHandling(
357357
renderedElement,
358358
hostParent,
@@ -480,7 +480,7 @@ var ReactCompositeComponent = {
480480
} catch (e) {
481481
// Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
482482
transaction.rollback(checkpoint);
483-
this._instance.unstable_handleError(e);
483+
this._instance.componentDidCatch(e);
484484
if (this._pendingStateQueue) {
485485
this._instance.state = this._processPendingState(
486486
this._instance.props,
@@ -1049,7 +1049,7 @@ var ReactCompositeComponent = {
10491049
inst.state = nextState;
10501050
inst.context = nextContext;
10511051

1052-
if (inst.unstable_handleError) {
1052+
if (inst.componentDidCatch) {
10531053
this._updateRenderedComponentWithErrorHandling(
10541054
transaction,
10551055
unmaskedContext,
@@ -1092,7 +1092,7 @@ var ReactCompositeComponent = {
10921092
// Roll back to checkpoint, handle error (which may add items to the transaction),
10931093
// and take a new checkpoint
10941094
transaction.rollback(checkpoint);
1095-
this._instance.unstable_handleError(e);
1095+
this._instance.componentDidCatch(e);
10961096
if (this._pendingStateQueue) {
10971097
this._instance.state = this._processPendingState(
10981098
this._instance.props,

src/renderers/testing/__tests__/ReactTestRenderer-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ describe('ReactTestRenderer', () => {
439439
onClick() {
440440
/* do nothing */
441441
}
442-
unstable_handleError() {
442+
componentDidCatch() {
443443
this.setState({error: true});
444444
}
445445
}

0 commit comments

Comments
 (0)