@samitouri / QOS-React / commits / 5bfb878743

Add note about mistaken named / default export (#11505)

This commit adds a note about the possibility of erroneously mistaking named and default exports to an existing error message.

Kristofer Selbekk committed Nov 9, 2017 at 19:28 UTC 5bfb87874391e635cb2458a29a7c878cb4dec89c
6 files changed +18 -11
packages/react-dom/src/__tests__/ReactComponent-test.js
+3 -2
@@ -342,7 +342,7 @@ describe('ReactComponent', () => {
342 'Element type is invalid: expected a string (for built-in components) ' +
343 'or a class/function (for composite components) but got: undefined. ' +
344 "You likely forgot to export your component from the file it's " +
345 - 'defined in.',
345 + 'defined in, or you might have mixed up default and named imports.',
346 );
347
348 var Y = null;
@@ -380,7 +380,8 @@ describe('ReactComponent', () => {
380 'Element type is invalid: expected a string (for built-in components) ' +
381 'or a class/function (for composite components) but got: undefined. ' +
382 "You likely forgot to export your component from the file it's " +
383 - 'defined in.\n\nCheck the render method of `Bar`.',
383 + 'defined in, or you might have mixed up default and named imports.' +
384 + '\n\nCheck the render method of `Bar`.',
385 );
386
387 // One warning for each element creation
packages/react-reconciler/src/ReactFiber.js
+1 -1
@@ -332,7 +332,7 @@ export function createFiberFromElement(
332 ) {
333 info +=
334 ' You likely forgot to export your component from the file ' +
335 - "it's defined in.";
335 + "it's defined in, or you might have mixed up default and named imports.";
336 }
337 const ownerName = owner ? getComponentName(owner) : null;
338 if (ownerName) {
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.js
+5 -3
@@ -749,7 +749,8 @@ describe('ReactIncrementalErrorHandling', () => {
749 'Element type is invalid: expected a string (for built-in components) or ' +
750 'a class/function (for composite components) but got: undefined. ' +
751 "You likely forgot to export your component from the file it's " +
752 - 'defined in.\n\nCheck the render method of `BrokenRender`.',
752 + 'defined in, or you might have mixed up default and named imports.' +
753 + '\n\nCheck the render method of `BrokenRender`.',
754 ),
755 ]);
756 expect(console.error.calls.count()).toBe(1);
@@ -794,7 +795,8 @@ describe('ReactIncrementalErrorHandling', () => {
795 'Element type is invalid: expected a string (for built-in components) or ' +
796 'a class/function (for composite components) but got: undefined. ' +
797 "You likely forgot to export your component from the file it's " +
797 - 'defined in.\n\nCheck the render method of `BrokenRender`.',
798 + 'defined in, or you might have mixed up default and named imports.' +
799 + '\n\nCheck the render method of `BrokenRender`.',
800 ),
801 ]);
802 expect(console.error.calls.count()).toBe(1);
@@ -810,7 +812,7 @@ describe('ReactIncrementalErrorHandling', () => {
812 'Element type is invalid: expected a string (for built-in components) or ' +
813 'a class/function (for composite components) but got: undefined. ' +
814 "You likely forgot to export your component from the file it's " +
813 - 'defined in.',
815 + 'defined in, or you might have mixed up default and named imports.',
816 );
817
818 ReactNoop.render(<span prop="hi" />);
packages/react/src/ReactElementValidator.js
+1 -1
@@ -285,7 +285,7 @@ export function createElementWithValidation(type, props, children) {
285 ) {
286 info +=
287 ' You likely forgot to export your component from the file ' +
288 - "it's defined in.";
288 + "it's defined in, or you might have mixed up default and named imports.";
289 }
290
291 var sourceInfo = getSourceInfoErrorAddendum(props);
packages/react/src/__tests__/ReactElementValidator-test.js
+6 -3
@@ -274,7 +274,8 @@ describe('ReactElementValidator', () => {
274 'Warning: React.createElement: type is invalid -- expected a string ' +
275 '(for built-in components) or a class/function (for composite ' +
276 'components) but got: undefined. You likely forgot to export your ' +
277 - "component from the file it's defined in.",
277 + "component from the file it's defined in, or you might have mixed up " +
278 + 'default and named imports.',
279 );
280 expectDev(console.error.calls.argsFor(1)[0]).toBe(
281 'Warning: React.createElement: type is invalid -- expected a string ' +
@@ -295,7 +296,8 @@ describe('ReactElementValidator', () => {
296 'Warning: React.createElement: type is invalid -- expected a string ' +
297 '(for built-in components) or a class/function (for composite ' +
298 'components) but got: object. You likely forgot to export your ' +
298 - "component from the file it's defined in.",
299 + "component from the file it's defined in, or you might have mixed up " +
300 + 'default and named imports.',
301 );
302 React.createElement('div');
303 expectDev(console.error.calls.count()).toBe(5);
@@ -511,7 +513,8 @@ describe('ReactElementValidator', () => {
513 'Warning: React.createElement: type is invalid -- expected a string ' +
514 '(for built-in components) or a class/function (for composite ' +
515 'components) but got: undefined. You likely forgot to export your ' +
514 - "component from the file it's defined in.\n\nCheck your code at **.",
516 + "component from the file it's defined in, or you might have mixed up " +
517 + 'default and named imports.\n\nCheck your code at **.',
518 );
519 });
520 });
packages/react/src/__tests__/ReactJSXElementValidator-test.js
+2 -1
@@ -330,7 +330,8 @@ describe('ReactJSXElementValidator', () => {
330 'Warning: React.createElement: type is invalid -- expected a string ' +
331 '(for built-in components) or a class/function (for composite ' +
332 'components) but got: undefined. You likely forgot to export your ' +
333 - "component from the file it's defined in." +
333 + "component from the file it's defined in, or you might have mixed up " +
334 + 'default and named imports.' +
335 '\n\nCheck your code at **.',
336 );
337 expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(