Skip to content

Commit 95d25db

Browse files
Added component stack to ReactFiber
Updated unit tests to expect component stack as well
1 parent 5d95b26 commit 95d25db

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

packages/react-reconciler/src/ReactFiber.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ import getComponentName from 'shared/getComponentName';
3737
import {NoWork} from './ReactFiberExpirationTime';
3838
import {NoContext} from './ReactTypeOfInternalContext';
3939

40+
import ReactDebugCurrentFiber from './ReactDebugCurrentFiber';
41+
42+
var {getCurrentFiberStackAddendum} = ReactDebugCurrentFiber;
43+
4044
if (__DEV__) {
4145
var hasBadMapPolyfill = false;
4246
try {
@@ -342,9 +346,10 @@ export function createFiberFromElement(
342346
invariant(
343347
false,
344348
'Element type is invalid: expected a string (for built-in components) ' +
345-
'or a class/function (for composite components) but got: %s.%s',
349+
'or a class/function (for composite components) but got: %s.%s%s',
346350
type == null ? type : typeof type,
347351
info,
352+
getCurrentFiberStackAddendum() || '',
348353
);
349354
}
350355

packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,9 @@ describe('ReactIncrementalErrorHandling', () => {
751751
(__DEV__
752752
? " You likely forgot to export your component from the file it's " +
753753
'defined in, or you might have mixed up default and named imports.' +
754-
'\n\nCheck the render method of `BrokenRender`.'
754+
'\n\nCheck the render method of `BrokenRender`.' +
755+
'\n in BrokenRender (at ReactIncrementalErrorHandling-test.js:743)' +
756+
'\n in ErrorBoundary (at ReactIncrementalErrorHandling-test.js:742)'
755757
: ''),
756758
),
757759
]);
@@ -804,7 +806,9 @@ describe('ReactIncrementalErrorHandling', () => {
804806
(__DEV__
805807
? " You likely forgot to export your component from the file it's " +
806808
'defined in, or you might have mixed up default and named imports.' +
807-
'\n\nCheck the render method of `BrokenRender`.'
809+
'\n\nCheck the render method of `BrokenRender`.' +
810+
'\n in BrokenRender (at ReactIncrementalErrorHandling-test.js:798)' +
811+
'\n in ErrorBoundary (at ReactIncrementalErrorHandling-test.js:797)'
808812
: ''),
809813
),
810814
]);

packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.internal.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,9 @@ describe('ReactIncrementalErrorLogging', () => {
755755
(__DEV__
756756
? " You likely forgot to export your component from the file it's " +
757757
'defined in, or you might have mixed up default and named imports.' +
758-
'\n\nCheck the render method of `BrokenRender`.'
758+
'\n\nCheck the render method of `BrokenRender`.' +
759+
'\n in BrokenRender (at ReactIncrementalErrorLogging-test.internal.js:747)' +
760+
'\n in ErrorBoundary (at ReactIncrementalErrorLogging-test.internal.js:746)'
759761
: ''),
760762
),
761763
]);
@@ -808,7 +810,9 @@ describe('ReactIncrementalErrorLogging', () => {
808810
(__DEV__
809811
? " You likely forgot to export your component from the file it's " +
810812
'defined in, or you might have mixed up default and named imports.' +
811-
'\n\nCheck the render method of `BrokenRender`.'
813+
'\n\nCheck the render method of `BrokenRender`.' +
814+
'\n in BrokenRender (at ReactIncrementalErrorLogging-test.internal.js:802)' +
815+
'\n in ErrorBoundary (at ReactIncrementalErrorLogging-test.internal.js:801)'
812816
: ''),
813817
),
814818
]);

0 commit comments

Comments
 (0)