@samitouri / QOS-React / commits / 2afcf6e09f

Fix formatting of invalid element invariant

Message is slightly different for functional and class components.

Andrew Clark committed Jan 31, 2017 at 15:29 UTC 2afcf6e09f6a710a0898b6bf097626079aa8719a
3 files changed +6 -5
scripts/fiber/tests-failing.txt
-3
@@ -50,9 +50,6 @@ src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
50 src/renderers/shared/shared/__tests__/ReactComponentLifeCycle-test.js
51 * should carry through each of the phases of setup
52
53 -src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
54 -* should still throw when rendering to undefined
55 -
53 src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
54 * should reorder keyed text nodes
55
scripts/fiber/tests-passing.txt
+1
@@ -1435,6 +1435,7 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponentState-test.js
1435
1436 src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
1437 * should not produce child DOM nodes for null and false
1438 +* should still throw when rendering to undefined
1439 * should be able to switch between rendering null and a normal tag
1440 * should be able to switch in a list of children
1441 * should distinguish between a script placeholder and an actual script tag
src/renderers/shared/fiber/ReactChildFiber.js
+5 -2
@@ -1189,8 +1189,10 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
1189 if (disableNewFiberFeatures) {
1190 // The new child is not an element. If it's not null or false,
1191 // and the return fiber is a composite component, throw an error.
1192 + let componentNameSuffix = '(...)';
1193 switch (returnFiber.tag) {
1194 case ClassComponent: {
1195 + componentNameSuffix = '.render()';
1196 if (__DEV__) {
1197 const instance = returnFiber.stateNode;
1198 if (instance.render._isMockFunction && typeof newChild === 'undefined') {
@@ -1208,10 +1210,11 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
1210 const Component = returnFiber.type;
1211 invariant(
1212 newChild === null || newChild === false,
1211 - '%s(...): A valid React element (or null) must be ' +
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.',
1214 - Component.displayName || Component.name || 'Component'
1216 + Component.displayName || Component.name || 'Component',
1217 + componentNameSuffix
1218 );
1219 }
1220 }