Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note about mistaken named / default export #11505

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/react-dom/src/__tests__/ReactComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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" />);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ReactElementValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions packages/react/src/__tests__/ReactElementValidator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' +
Expand All @@ -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);
Expand Down Expand Up @@ -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 **.',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down