Skip to content

Commit f343031

Browse files
committed
Delete use of source in JSX runtime
Only remaining place it was being used was in a warning message.
1 parent 47beb96 commit f343031

File tree

3 files changed

+6
-37
lines changed

3 files changed

+6
-37
lines changed

packages/react/src/__tests__/ReactElementValidator-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ describe('ReactElementValidator', () => {
427427
'(for built-in components) or a class/function (for composite ' +
428428
'components) but got: undefined. You likely forgot to export your ' +
429429
"component from the file it's defined in, or you might have mixed up " +
430-
'default and named imports.\n\nCheck your code at **.',
430+
'default and named imports.',
431431
{withoutStack: true},
432432
);
433433
});

packages/react/src/__tests__/ReactJSXElementValidator-test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,19 @@ describe('ReactJSXElementValidator', () => {
170170
'(for built-in components) or a class/function (for composite ' +
171171
'components) but got: undefined. You likely forgot to export your ' +
172172
"component from the file it's defined in, or you might have mixed up " +
173-
'default and named imports.' +
174-
'\n\nCheck your code at **.',
173+
'default and named imports.',
175174
{withoutStack: true},
176175
);
177176
expect(() => void (<Null />)).toErrorDev(
178177
'Warning: React.jsx: type is invalid -- expected a string ' +
179178
'(for built-in components) or a class/function (for composite ' +
180-
'components) but got: null.' +
181-
'\n\nCheck your code at **.',
179+
'components) but got: null.',
182180
{withoutStack: true},
183181
);
184182
expect(() => void (<True />)).toErrorDev(
185183
'Warning: React.jsx: type is invalid -- expected a string ' +
186184
'(for built-in components) or a class/function (for composite ' +
187-
'components) but got: boolean.' +
188-
'\n\nCheck your code at **.',
185+
'components) but got: boolean.',
189186
{withoutStack: true},
190187
);
191188
// No error expected

packages/react/src/jsx/ReactJSXElement.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,7 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
425425
"it's defined in, or you might have mixed up default and named imports.";
426426
}
427427

428-
const sourceInfo = getSourceInfoErrorAddendum(source);
429-
if (sourceInfo) {
430-
info += sourceInfo;
431-
} else {
432-
info += getDeclarationErrorAddendum();
433-
}
428+
info += getDeclarationErrorAddendum();
434429

435430
let typeString;
436431
if (type === null) {
@@ -622,12 +617,7 @@ export function createElement(type, config, children) {
622617
"it's defined in, or you might have mixed up default and named imports.";
623618
}
624619

625-
const sourceInfo = getSourceInfoErrorAddendumForProps(config);
626-
if (sourceInfo) {
627-
info += sourceInfo;
628-
} else {
629-
info += getDeclarationErrorAddendum();
630-
}
620+
info += getDeclarationErrorAddendum();
631621

632622
let typeString;
633623
if (type === null) {
@@ -939,24 +929,6 @@ function getDeclarationErrorAddendum() {
939929
}
940930
}
941931

942-
function getSourceInfoErrorAddendumForProps(elementProps) {
943-
if (elementProps !== null && elementProps !== undefined) {
944-
return getSourceInfoErrorAddendum(elementProps.__source);
945-
}
946-
return '';
947-
}
948-
949-
function getSourceInfoErrorAddendum(source) {
950-
if (__DEV__) {
951-
if (source !== undefined) {
952-
const fileName = source.fileName.replace(/^.*[\\\/]/, '');
953-
const lineNumber = source.lineNumber;
954-
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
955-
}
956-
return '';
957-
}
958-
}
959-
960932
/**
961933
* Ensure that every element either is passed in a static location, in an
962934
* array with an explicit keys property defined, or in an object literal

0 commit comments

Comments
 (0)