mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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.
This commit is contained in:
1 parent
ac0e670545
commit
5bfb878743
6 files changed
+18
-11
No files matched your search
+3
-2
@@ -342,7 +342,7 @@ describe('ReactComponent', () => {
|
||||
'Element type is invalid: expected a string (for built-in components) ' +
|
||||
'or a class/function (for composite components) but got: undefined. ' +
|
||||
"You likely forgot to export your component from the file it's " +
|
||||
'defined in.',
|
||||
'defined in, or you might have mixed up default and named imports.',
|
||||
);
|
||||
|
||||
var Y = null;
|
||||
@@ -380,7 +380,8 @@ describe('ReactComponent', () => {
|
||||
'Element type is invalid: expected a string (for built-in components) ' +
|
||||
'or a class/function (for composite components) but got: undefined. ' +
|
||||
"You likely forgot to export your component from the file it's " +
|
||||
'defined in.\n\nCheck the render method of `Bar`.',
|
||||
'defined in, or you might have mixed up default and named imports.' +
|
||||
'\n\nCheck the render method of `Bar`.',
|
||||
);
|
||||
|
||||
// One warning for each element creation
|
||||
|
||||
+1
-1
@@ -332,7 +332,7 @@ export function createFiberFromElement(
|
||||
) {
|
||||
info +=
|
||||
' You likely forgot to export your component from the file ' +
|
||||
"it's defined in.";
|
||||
"it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
const ownerName = owner ? getComponentName(owner) : null;
|
||||
if (ownerName) {
|
||||
|
||||
+5
-3
@@ -749,7 +749,8 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
'Element type is invalid: expected a string (for built-in components) or ' +
|
||||
'a class/function (for composite components) but got: undefined. ' +
|
||||
"You likely forgot to export your component from the file it's " +
|
||||
'defined in.\n\nCheck the render method of `BrokenRender`.',
|
||||
'defined in, or you might have mixed up default and named imports.' +
|
||||
'\n\nCheck the render method of `BrokenRender`.',
|
||||
),
|
||||
]);
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
@@ -794,7 +795,8 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
'Element type is invalid: expected a string (for built-in components) or ' +
|
||||
'a class/function (for composite components) but got: undefined. ' +
|
||||
"You likely forgot to export your component from the file it's " +
|
||||
'defined in.\n\nCheck the render method of `BrokenRender`.',
|
||||
'defined in, or you might have mixed up default and named imports.' +
|
||||
'\n\nCheck the render method of `BrokenRender`.',
|
||||
),
|
||||
]);
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
@@ -810,7 +812,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
'Element type is invalid: expected a string (for built-in components) or ' +
|
||||
'a class/function (for composite components) but got: undefined. ' +
|
||||
"You likely forgot to export your component from the file it's " +
|
||||
'defined in.',
|
||||
'defined in, or you might have mixed up default and named imports.',
|
||||
);
|
||||
|
||||
ReactNoop.render(<span prop="hi" />);
|
||||
|
||||
@@ -285,7 +285,7 @@ export function createElementWithValidation(type, props, children) {
|
||||
) {
|
||||
info +=
|
||||
' You likely forgot to export your component from the file ' +
|
||||
"it's defined in.";
|
||||
"it's defined in, or you might have mixed up default and named imports.";
|
||||
}
|
||||
|
||||
var sourceInfo = getSourceInfoErrorAddendum(props);
|
||||
|
||||
@@ -274,7 +274,8 @@ describe('ReactElementValidator', () => {
|
||||
'Warning: React.createElement: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: undefined. You likely forgot to export your ' +
|
||||
"component from the file it's defined in.",
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.',
|
||||
);
|
||||
expectDev(console.error.calls.argsFor(1)[0]).toBe(
|
||||
'Warning: React.createElement: type is invalid -- expected a string ' +
|
||||
@@ -295,7 +296,8 @@ describe('ReactElementValidator', () => {
|
||||
'Warning: React.createElement: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: object. You likely forgot to export your ' +
|
||||
"component from the file it's defined in.",
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.',
|
||||
);
|
||||
React.createElement('div');
|
||||
expectDev(console.error.calls.count()).toBe(5);
|
||||
@@ -511,7 +513,8 @@ describe('ReactElementValidator', () => {
|
||||
'Warning: React.createElement: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: undefined. You likely forgot to export your ' +
|
||||
"component from the file it's defined in.\n\nCheck your code at **.",
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.\n\nCheck your code at **.',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -330,7 +330,8 @@ describe('ReactJSXElementValidator', () => {
|
||||
'Warning: React.createElement: type is invalid -- expected a string ' +
|
||||
'(for built-in components) or a class/function (for composite ' +
|
||||
'components) but got: undefined. You likely forgot to export your ' +
|
||||
"component from the file it's defined in." +
|
||||
"component from the file it's defined in, or you might have mixed up " +
|
||||
'default and named imports.' +
|
||||
'\n\nCheck your code at **.',
|
||||
);
|
||||
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
|
||||
|
||||
Reference in new issue
Block a user