Skip to content

Commit da55ccf

Browse files
authored
Revert "Loosen assertion so it matches any production error"
1 parent 57d2d6d commit da55ccf

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

scripts/fiber/tests-failing.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
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+
47
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
58
* should clean up input value tracking
69
* should clean up input textarea tracking

scripts/fiber/tests-passing.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ 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
527526
* should keep track of namespace across portals in production
528527

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

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

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

186186
var container = document.createElement('div');
187187
ReactDOM.render(<Component />, container);
188-
}).toThrowError('Minified React error #');
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+
);
189194
});
190195

191196
if (ReactDOMFeatureFlags.useFiber) {

src/renderers/shared/fiber/ReactChildFiber.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,8 +1189,10 @@ 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 = '(...)';
11921193
switch (returnFiber.tag) {
11931194
case ClassComponent: {
1195+
componentNameSuffix = '.render()';
11941196
if (__DEV__) {
11951197
const instance = returnFiber.stateNode;
11961198
if (instance.render._isMockFunction && typeof newChild === 'undefined') {
@@ -1199,27 +1201,21 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
11991201
break;
12001202
}
12011203
}
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;
12111204
}
1205+
// Intentionally fall through to the next case, which handles both
1206+
// functions and classes
1207+
// eslint-disable-next-lined no-fallthrough
12121208
case FunctionalComponent: {
12131209
// Composites accept elements, portals, null, or false
12141210
const Component = returnFiber.type;
12151211
invariant(
12161212
newChild === null || newChild === false,
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.',
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.',
12201216
Component.displayName || Component.name || 'Component',
1217+
componentNameSuffix
12211218
);
1222-
break;
12231219
}
12241220
}
12251221
}

0 commit comments

Comments
 (0)