diff --git a/packages/react/src/__tests__/ReactElementValidator-test.internal.js b/packages/react/src/__tests__/ReactElementValidator-test.internal.js index 3bfded6d6d8242..5bd6d2417d2743 100644 --- a/packages/react/src/__tests__/ReactElementValidator-test.internal.js +++ b/packages/react/src/__tests__/ReactElementValidator-test.internal.js @@ -427,7 +427,7 @@ describe('ReactElementValidator', () => { '(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, or you might have mixed up " + - 'default and named imports.\n\nCheck your code at **.', + 'default and named imports.', {withoutStack: true}, ); }); diff --git a/packages/react/src/__tests__/ReactJSXElementValidator-test.js b/packages/react/src/__tests__/ReactJSXElementValidator-test.js index 93293b54ff5443..b34de9e67a4cb9 100644 --- a/packages/react/src/__tests__/ReactJSXElementValidator-test.js +++ b/packages/react/src/__tests__/ReactJSXElementValidator-test.js @@ -170,22 +170,19 @@ describe('ReactJSXElementValidator', () => { '(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, or you might have mixed up " + - 'default and named imports.' + - '\n\nCheck your code at **.', + 'default and named imports.', {withoutStack: true}, ); expect(() => void ()).toErrorDev( 'Warning: React.jsx: type is invalid -- expected a string ' + '(for built-in components) or a class/function (for composite ' + - 'components) but got: null.' + - '\n\nCheck your code at **.', + 'components) but got: null.', {withoutStack: true}, ); expect(() => void ()).toErrorDev( 'Warning: React.jsx: type is invalid -- expected a string ' + '(for built-in components) or a class/function (for composite ' + - 'components) but got: boolean.' + - '\n\nCheck your code at **.', + 'components) but got: boolean.', {withoutStack: true}, ); // No error expected diff --git a/packages/react/src/jsx/ReactJSXElement.js b/packages/react/src/jsx/ReactJSXElement.js index 59e7b6e5e31149..7289057ee49f5f 100644 --- a/packages/react/src/jsx/ReactJSXElement.js +++ b/packages/react/src/jsx/ReactJSXElement.js @@ -425,12 +425,7 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) { "it's defined in, or you might have mixed up default and named imports."; } - const sourceInfo = getSourceInfoErrorAddendum(source); - if (sourceInfo) { - info += sourceInfo; - } else { - info += getDeclarationErrorAddendum(); - } + info += getDeclarationErrorAddendum(); let typeString; if (type === null) { @@ -622,12 +617,7 @@ export function createElement(type, config, children) { "it's defined in, or you might have mixed up default and named imports."; } - const sourceInfo = getSourceInfoErrorAddendumForProps(config); - if (sourceInfo) { - info += sourceInfo; - } else { - info += getDeclarationErrorAddendum(); - } + info += getDeclarationErrorAddendum(); let typeString; if (type === null) { @@ -939,24 +929,6 @@ function getDeclarationErrorAddendum() { } } -function getSourceInfoErrorAddendumForProps(elementProps) { - if (elementProps !== null && elementProps !== undefined) { - return getSourceInfoErrorAddendum(elementProps.__source); - } - return ''; -} - -function getSourceInfoErrorAddendum(source) { - if (__DEV__) { - if (source !== undefined) { - const fileName = source.fileName.replace(/^.*[\\\/]/, ''); - const lineNumber = source.lineNumber; - return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; - } - return ''; - } -} - /** * Ensure that every element either is passed in a static location, in an * array with an explicit keys property defined, or in an object literal