Skip to content

Commit 23f9e7b

Browse files
authored
Merge pull request #8937 from acdlite/inlineinternalerrormessage
Inline internal error message
2 parents 2c7c783 + 2e1b3aa commit 23f9e7b

File tree

7 files changed

+67
-86
lines changed

7 files changed

+67
-86
lines changed

src/renderers/shared/fiber/ReactChildFiber.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ const {
7373
Deletion,
7474
} = ReactTypeOfSideEffect;
7575

76-
const internalErrorMessage =
77-
'This error is likely caused by a bug in React. Please file an issue.';
78-
7976
function coerceRef(current: ?Fiber, element: ReactElement) {
8077
let mixedRef = element.ref;
8178
if (mixedRef != null && typeof mixedRef !== 'function') {
@@ -93,9 +90,10 @@ function coerceRef(current: ?Fiber, element: ReactElement) {
9390
}
9491
}
9592
invariant(
96-
inst, 'Missing owner for string ref %s. (%s)',
97-
mixedRef,
98-
internalErrorMessage
93+
inst,
94+
'Missing owner for string ref %s. This error is likely caused by a ' +
95+
'bug in React. Please file an issue.',
96+
mixedRef
9997
);
10098
const stringRef = String(mixedRef);
10199
// Check if previous string ref matches new string ref
@@ -807,8 +805,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
807805
const iteratorFn = getIteratorFn(newChildrenIterable);
808806
invariant(
809807
typeof iteratorFn === 'function',
810-
'An object is not an iterable. (%s)',
811-
internalErrorMessage
808+
'An object is not an iterable. This error is likely caused by a bug in ' +
809+
'React. Please file an issue.'
812810
);
813811

814812
if (__DEV__) {

src/renderers/shared/fiber/ReactFiberBeginWork.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ if (__DEV__) {
7171
var warnedAboutStatelessRefs = {};
7272
}
7373

74-
const internalErrorMessage =
75-
'This error is likely caused by a bug in React. Please file an issue.';
76-
7774
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
7875
config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
7976
hostContext : HostContext<C, CX>,
@@ -347,8 +344,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
347344
nextProps = memoizedProps;
348345
invariant(
349346
nextProps !== null,
350-
'We should always have pending or current props. (%s)',
351-
internalErrorMessage
347+
'We should always have pending or current props. This error is ' +
348+
'likely caused by a bug in React. Please file an issue.'
352349
);
353350
}
354351
} else if (nextProps === null || memoizedProps === nextProps) {
@@ -450,8 +447,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
450447
function mountIndeterminateComponent(current, workInProgress, priorityLevel) {
451448
invariant(
452449
current === null,
453-
'An indeterminate component should never have mounted. (%s)',
454-
internalErrorMessage
450+
'An indeterminate component should never have mounted. This error is ' +
451+
'likely caused by a bug in React. Please file an issue.'
455452
);
456453
var fn = workInProgress.type;
457454
var props = workInProgress.pendingProps;
@@ -521,8 +518,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
521518
nextCoroutine = current && current.memoizedProps;
522519
invariant(
523520
nextCoroutine != null,
524-
'We should always have pending or current props. (%s)',
525-
internalErrorMessage
521+
'We should always have pending or current props. This error is ' +
522+
'likely caused by a bug in React. Please file an issue.'
526523
);
527524
}
528525
} else if (nextCoroutine === null || workInProgress.memoizedProps === nextCoroutine) {
@@ -587,8 +584,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
587584
nextChildren = current && current.memoizedProps;
588585
invariant(
589586
nextChildren != null,
590-
'We should always have pending or current props. (%s)',
591-
internalErrorMessage
587+
'We should always have pending or current props. This error is ' +
588+
'likely caused by a bug in React. Please file an issue.'
592589
);
593590
}
594591
} else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) {
@@ -741,8 +738,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
741738
default:
742739
invariant(
743740
false,
744-
'Unknown unit of work tag. (%s)',
745-
internalErrorMessage
741+
'Unknown unit of work tag. This error is likely caused by a bug in ' +
742+
'React. Please file an issue.'
746743
);
747744
}
748745
}
@@ -751,8 +748,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
751748
invariant(
752749
workInProgress.tag === ClassComponent ||
753750
workInProgress.tag === HostRoot,
754-
'Invalid type of work. (%s)',
755-
internalErrorMessage
751+
'Invalid type of work. This error is likely caused by a bug in React. ' +
752+
'Please file an issue.'
756753
);
757754

758755
// Add an error effect so we can handle the error during the commit phase

src/renderers/shared/fiber/ReactFiberClassComponent.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ var invariant = require('invariant');
4040

4141
const isArray = Array.isArray;
4242

43-
const internalErrorMessage =
44-
'This error is likely caused by a bug in React. Please file an issue.';
45-
4643
module.exports = function(
4744
scheduleUpdate : (fiber : Fiber, priorityLevel : PriorityLevel) => void,
4845
getPriorityContext : () => PriorityLevel,
@@ -262,8 +259,8 @@ module.exports = function(
262259
let props = workInProgress.pendingProps;
263260
invariant(
264261
props,
265-
'There must be pending props for an initial mount. (%s)',
266-
internalErrorMessage
262+
'There must be pending props for an initial mount. This error is ' +
263+
'likely caused by a bug in React. Please file an issue.'
267264
);
268265

269266
const unmaskedContext = getUnmaskedContext(workInProgress);
@@ -305,8 +302,8 @@ module.exports = function(
305302
newProps = workInProgress.memoizedProps;
306303
invariant(
307304
newProps != null,
308-
'There should always be pending or memoized props. (%s)',
309-
internalErrorMessage
305+
'There should always be pending or memoized props. This error is ' +
306+
'likely caused by a bug in React. Please file an issue.'
310307
);
311308
}
312309
const newUnmaskedContext = getUnmaskedContext(workInProgress);
@@ -372,8 +369,8 @@ module.exports = function(
372369
newProps = oldProps;
373370
invariant(
374371
newProps != null,
375-
'There should always be pending or memoized props. (%s)',
376-
internalErrorMessage
372+
'There should always be pending or memoized props. This error is ' +
373+
'likely caused by a bug in React. Please file an issue.'
377374
);
378375
}
379376
const oldContext = instance.context;

src/renderers/shared/fiber/ReactFiberCommitWork.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ var {
3636

3737
var invariant = require('invariant');
3838

39-
const internalErrorMessage =
40-
'This error is likely caused by a bug in React. Please file an issue.';
41-
4239
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
4340
config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
4441
captureError : (failedFiber : Fiber, error: Error) => ?Fiber
@@ -101,8 +98,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
10198
}
10299
invariant(
103100
false,
104-
'Expected to find a host parent. (%s)',
105-
internalErrorMessage
101+
'Expected to find a host parent. This error is likely caused by a bug ' +
102+
'in React. Please file an issue.'
106103
);
107104
}
108105

@@ -116,8 +113,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
116113
}
117114
invariant(
118115
false,
119-
'Expected to find a host parent. (%s)',
120-
internalErrorMessage
116+
'Expected to find a host parent. This error is likely caused by a bug ' +
117+
'in React. Please file an issue.'
121118
);
122119
}
123120

@@ -188,8 +185,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
188185
default:
189186
invariant(
190187
false,
191-
'Invalid host parent fiber. (%s)',
192-
internalErrorMessage
188+
'Invalid host parent fiber. This error is likely caused by a bug ' +
189+
'in React. Please file an issue.'
193190
);
194191
}
195192
if (parentFiber.effectTag & ContentReset) {
@@ -393,8 +390,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
393390
case HostText: {
394391
invariant(
395392
finishedWork.stateNode !== null && current != null,
396-
'This should only be done during updates. (%s)',
397-
internalErrorMessage
393+
'This should only be done during updates. This error is likely ' +
394+
'caused by a bug in React. Please file an issue.'
398395
);
399396
const textInstance : TI = finishedWork.stateNode;
400397
const newText : string = finishedWork.memoizedProps;
@@ -411,8 +408,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
411408
default: {
412409
invariant(
413410
false,
414-
'This unit of work tag should not have side-effects. (%s)',
415-
internalErrorMessage
411+
'This unit of work tag should not have side-effects. This error is ' +
412+
'likely caused by a bug in React. Please file an issue.'
416413
);
417414
}
418415
}
@@ -477,8 +474,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
477474
default: {
478475
invariant(
479476
false,
480-
'This unit of work tag should not have side-effects. (%s)',
481-
internalErrorMessage
477+
'This unit of work tag should not have side-effects. This error is ' +
478+
'likely caused by a bug in React. Please file an issue.'
482479
);
483480
}
484481
}

src/renderers/shared/fiber/ReactFiberCompleteWork.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ if (__DEV__) {
4848

4949
var invariant = require('invariant');
5050

51-
const internalErrorMessage =
52-
'This error is likely caused by a bug in React. Please file an issue.';
53-
5451
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
5552
config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
5653
hostContext : HostContext<C, CX>,
@@ -122,8 +119,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
122119
var coroutine = (workInProgress.memoizedProps : ?ReactCoroutine);
123120
invariant(
124121
coroutine,
125-
'Should be resolved by now. (%s)',
126-
internalErrorMessage
122+
'Should be resolved by now. This error is likely caused by a bug in ' +
123+
'React. Please file an issue.',
127124
);
128125

129126
// First step of the coroutine has completed. Now we need to do the second.
@@ -241,8 +238,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
241238
if (!newProps) {
242239
invariant(
243240
workInProgress.stateNode !== null,
244-
'We must have new props for new mounts. (%s)',
245-
internalErrorMessage
241+
'We must have new props for new mounts. This error is likely ' +
242+
'caused by a bug in React. Please file an issue.'
246243
);
247244
// This can happen when we abort work.
248245
return null;
@@ -291,8 +288,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
291288
if (typeof newText !== 'string') {
292289
invariant(
293290
workInProgress.stateNode !== null,
294-
'We must have new props for new mounts. (%s)',
295-
internalErrorMessage
291+
'We must have new props for new mounts. This error is likely ' +
292+
'caused by a bug in React. Please file an issue.'
296293
);
297294
// This can happen when we abort work.
298295
return null;
@@ -325,15 +322,16 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
325322
case IndeterminateComponent:
326323
invariant(
327324
false,
328-
'An indeterminate component should have become determinate before completing. (%s)',
329-
internalErrorMessage
325+
'An indeterminate component should have become determinate before ' +
326+
'completing. This error is likely caused by a bug in React. Please ' +
327+
'file an issue.'
330328
);
331329
// eslint-disable-next-line no-fallthrough
332330
default:
333331
invariant(
334332
false,
335-
'Unknown unit of work tag. (%s)',
336-
internalErrorMessage
333+
'Unknown unit of work tag. This error is likely caused by a bug in ' +
334+
'React. Please file an issue.'
337335
);
338336
}
339337
}

src/renderers/shared/fiber/ReactFiberHostContext.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ export type HostContext<C, CX> = {
3636
resetHostContainer() : void,
3737
};
3838

39-
const internalErrorMessage =
40-
'This error is likely caused by a bug in React. Please file an issue.';
41-
4239
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
4340
config : HostConfig<T, P, I, TI, PI, C, CX, PL>
4441
) : HostContext<C, CX> {
@@ -55,8 +52,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
5552
const rootInstance = rootInstanceStackCursor.current;
5653
invariant(
5754
rootInstance != null,
58-
'Expected root container to exist. (%s)',
59-
internalErrorMessage
55+
'Expected root container to exist. This error is likely caused by a ' +
56+
'bug in React. Please file an issue.'
6057
);
6158
return rootInstance;
6259
}
@@ -84,8 +81,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
8481
const context = contextStackCursor.current;
8582
invariant(
8683
context != null,
87-
'Expected host context to exist. (%s)',
88-
internalErrorMessage
84+
'Expected host context to exist. This error is likely caused by a bug ' +
85+
'in React. Please file an issue.'
8986
);
9087
return context;
9188
}
@@ -94,8 +91,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
9491
const rootInstance = rootInstanceStackCursor.current;
9592
invariant(
9693
rootInstance != null,
97-
'Expected root host context to exist. (%s)',
98-
internalErrorMessage
94+
'Expected root host context to exist. This error is likely caused by ' +
95+
'a bug in React. Please file an issue.'
9996
);
10097

10198
const context = contextStackCursor.current || emptyObject;

0 commit comments

Comments
 (0)