Skip to content

Commit 57d2d6d

Browse files
authored
Merge pull request #8907 from acdlite/fiberproderrorcode
Loosen assertion so it matches any production error
2 parents 7e8068b + ea2aa6e commit 57d2d6d

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

scripts/fiber/tests-failing.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
22
* should pass previous context to lifecycles
33

4-
src/renderers/dom/__tests__/ReactDOMProduction-test.js
5-
* should throw with an error code in production
6-
74
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
85
* should clean up input value tracking
96
* should clean up input textarea tracking

scripts/fiber/tests-passing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ src/renderers/dom/__tests__/ReactDOMProduction-test.js
523523
* should use prod React
524524
* should handle a simple flow
525525
* should call lifecycle methods
526+
* should throw with an error code in production
526527
* should keep track of namespace across portals in production
527528

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

src/renderers/dom/__tests__/ReactDOMProduction-test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,7 @@ describe('ReactDOMProduction', () => {
185185

186186
var container = document.createElement('div');
187187
ReactDOM.render(<Component />, container);
188-
}).toThrowError(
189-
'Minified React error #109; visit ' +
190-
'http://facebook.github.io/react/docs/error-decoder.html?invariant=109&args[]=Component' +
191-
' for the full message or use the non-minified dev environment' +
192-
' for full errors and additional helpful warnings.'
193-
);
188+
}).toThrowError('Minified React error #');
194189
});
195190

196191
if (ReactDOMFeatureFlags.useFiber) {

src/renderers/shared/fiber/ReactChildFiber.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,10 +1189,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
11891189
if (disableNewFiberFeatures) {
11901190
// The new child is not an element. If it's not null or false,
11911191
// and the return fiber is a composite component, throw an error.
1192-
let componentNameSuffix = '(...)';
11931192
switch (returnFiber.tag) {
11941193
case ClassComponent: {
1195-
componentNameSuffix = '.render()';
11961194
if (__DEV__) {
11971195
const instance = returnFiber.stateNode;
11981196
if (instance.render._isMockFunction && typeof newChild === 'undefined') {
@@ -1201,21 +1199,27 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
12011199
break;
12021200
}
12031201
}
1202+
const Component = returnFiber.type;
1203+
invariant(
1204+
newChild === null || newChild === false,
1205+
'%s.render(): A valid React element (or null) must be returned. ' +
1206+
'You may have returned undefined, an array or some other ' +
1207+
'invalid object.',
1208+
Component.displayName || Component.name || 'Component',
1209+
);
1210+
break;
12041211
}
1205-
// Intentionally fall through to the next case, which handles both
1206-
// functions and classes
1207-
// eslint-disable-next-lined no-fallthrough
12081212
case FunctionalComponent: {
12091213
// Composites accept elements, portals, null, or false
12101214
const Component = returnFiber.type;
12111215
invariant(
12121216
newChild === null || newChild === false,
1213-
'%s%s: A valid React element (or null) must be ' +
1214-
'returned. You may have returned undefined, an array or some ' +
1215-
'other invalid object.',
1217+
'%s(...): A valid React element (or null) must be returned. ' +
1218+
'You may have returned undefined, an array or some other ' +
1219+
'invalid object.',
12161220
Component.displayName || Component.name || 'Component',
1217-
componentNameSuffix
12181221
);
1222+
break;
12191223
}
12201224
}
12211225
}

0 commit comments

Comments
 (0)