mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Fix messages so that they use the same template as Stack
The production error code system depends on the exact template string that is passed to `invariant`. This changes the Fiber templates to match the Stack ones.
This commit is contained in:
1 parent
02edc6bf18
commit
ea2aa6e613
1 file changed
+13
-9
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user