@samitouri / QOS-React / commits / ea2aa6e613

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.

Andrew Clark committed Feb 2, 2017 at 12:05 UTC ea2aa6e613b7009f5b3680057eb00d728c7333b1
1 file changed +13 -9
src/renderers/shared/fiber/ReactChildFiber.js
+13 -9
@@ -1189,10 +1189,8 @@ 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 = '(...)';
1192 switch (returnFiber.tag) {
1193 case ClassComponent: {
1195 - componentNameSuffix = '.render()';
1194 if (__DEV__) {
1195 const instance = returnFiber.stateNode;
1196 if (instance.render._isMockFunction && typeof newChild === 'undefined') {
@@ -1201,21 +1199,27 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
1199 break;
1200 }
1201 }
1202 + const Component = returnFiber.type;
1203 + invariant(
1204 + newChild === null || newChild === false,
1205 + '%s.render(): A valid React element (or null) must be returned. ' +
1206 + 'You may have returned undefined, an array or some other ' +
1207 + 'invalid object.',
1208 + Component.displayName || Component.name || 'Component',
1209 + );
1210 + break;
1211 }
1205 - // Intentionally fall through to the next case, which handles both
1206 - // functions and classes
1207 - // eslint-disable-next-lined no-fallthrough
1212 case FunctionalComponent: {
1213 // Composites accept elements, portals, null, or false
1214 const Component = returnFiber.type;
1215 invariant(
1216 newChild === null || newChild === false,
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.',
1217 + '%s(...): A valid React element (or null) must be returned. ' +
1218 + 'You may have returned undefined, an array or some other ' +
1219 + 'invalid object.',
1220 Component.displayName || Component.name || 'Component',
1217 - componentNameSuffix
1221 );
1222 + break;
1223 }
1224 }
1225 }