mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Fix formatting of invalid element invariant
Message is slightly different for functional and class components.
This commit is contained in:
@@ -50,9 +50,6 @@ src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
|
||||
src/renderers/shared/shared/__tests__/ReactComponentLifeCycle-test.js
|
||||
* should carry through each of the phases of setup
|
||||
|
||||
src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
|
||||
* should still throw when rendering to undefined
|
||||
|
||||
src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
|
||||
* should reorder keyed text nodes
|
||||
|
||||
|
||||
@@ -1435,6 +1435,7 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponentState-test.js
|
||||
|
||||
src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
|
||||
* should not produce child DOM nodes for null and false
|
||||
* should still throw when rendering to undefined
|
||||
* should be able to switch between rendering null and a normal tag
|
||||
* should be able to switch in a list of children
|
||||
* should distinguish between a script placeholder and an actual script tag
|
||||
|
||||
@@ -1189,8 +1189,10 @@ 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') {
|
||||
@@ -1208,10 +1210,11 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
const Component = returnFiber.type;
|
||||
invariant(
|
||||
newChild === null || newChild === false,
|
||||
'%s(...): A valid React element (or null) must be ' +
|
||||
'%s%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'
|
||||
Component.displayName || Component.name || 'Component',
|
||||
componentNameSuffix
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user