Merge pull request #8907 from acdlite/fiberproderrorcode

Loosen assertion so it matches any production error
This commit is contained in:
Andrew Clark authored and GitHub committed 2017-02-02 14:42:23 -08:00
commit 57d2d6d77d
4 files changed
+15 -18

No files matched your search

@@ -185,12 +185,7 @@ describe('ReactDOMProduction', () => {
var container = document.createElement('div');
ReactDOM.render(<Component />, container);
}).toThrowError(
'Minified React error #109; visit ' +
'http://facebook.github.io/react/docs/error-decoder.html?invariant=109&args[]=Component' +
' for the full message or use the non-minified dev environment' +
' for full errors and additional helpful warnings.'
);
}).toThrowError('Minified React error #');
});
if (ReactDOMFeatureFlags.useFiber) {
+13 -9
View File
@@ -1189,10 +1189,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
if (disableNewFiberFeatures) {
// The new child is not an element. If it's not null or false,
// and the return fiber is a composite component, throw an error.
let componentNameSuffix = '(...)';
switch (returnFiber.tag) {
case ClassComponent: {
componentNameSuffix = '.render()';
if (__DEV__) {
const instance = returnFiber.stateNode;
if (instance.render._isMockFunction && typeof newChild === 'undefined') {
@@ -1201,21 +1199,27 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
break;
}
}
const Component = returnFiber.type;
invariant(
newChild === null || newChild === false,
'%s.render(): A valid React element (or null) must be returned. ' +
'You may have returned undefined, an array or some other ' +
'invalid object.',
Component.displayName || Component.name || 'Component',
);
break;
}
// Intentionally fall through to the next case, which handles both
// functions and classes
// eslint-disable-next-lined no-fallthrough
case FunctionalComponent: {
// Composites accept elements, portals, null, or false
const Component = returnFiber.type;
invariant(
newChild === null || newChild === false,
'%s%s: A valid React element (or null) must be ' +
'returned. You may have returned undefined, an array or some ' +
'other invalid object.',
'%s(...): A valid React element (or null) must be returned. ' +
'You may have returned undefined, an array or some other ' +
'invalid object.',
Component.displayName || Component.name || 'Component',
componentNameSuffix
);
break;
}
}
}