diff --git a/scripts/fiber/tests-failing.txt b/scripts/fiber/tests-failing.txt index d14ca51e78d..06137eac049 100644 --- a/scripts/fiber/tests-failing.txt +++ b/scripts/fiber/tests-failing.txt @@ -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 diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 04c72a219f9..3b85124db56 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -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 diff --git a/src/renderers/shared/fiber/ReactChildFiber.js b/src/renderers/shared/fiber/ReactChildFiber.js index 24a95016994..646007ceff6 100644 --- a/src/renderers/shared/fiber/ReactChildFiber.js +++ b/src/renderers/shared/fiber/ReactChildFiber.js @@ -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 ); } }