Skip to content

Commit 16d3f78

Browse files
authored
Delete use of source in JSX runtime (#28433)
Only remaining place it was being used was in a warning message.
1 parent d579e77 commit 16d3f78

File tree

3 files changed

+8
-43
lines changed

3 files changed

+8
-43
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ describe('ReactElementValidator', () => {
310310
}).toErrorDev([
311311
'Warning: React.createElement: type is invalid -- expected a string ' +
312312
'(for built-in components) or a class/function (for composite ' +
313-
'components) but got: null.' +
314-
'\n\nCheck the render method of `ParentComp`.\n in ParentComp',
313+
'components) but got: null.\n' +
314+
' in ParentComp (at **)',
315315
'Warning: React.createElement: type is invalid -- expected a string ' +
316316
'(for built-in components) or a class/function (for composite ' +
317-
'components) but got: null.' +
318-
'\n\nCheck the render method of `ParentComp`.\n in ParentComp',
317+
'components) but got: null.\n' +
318+
' in ParentComp (at **)',
319319
]);
320320
});
321321

@@ -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: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,6 @@ 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-
}
434-
435428
let typeString;
436429
if (type === null) {
437430
typeString = 'null';
@@ -622,13 +615,6 @@ export function createElement(type, config, children) {
622615
"it's defined in, or you might have mixed up default and named imports.";
623616
}
624617

625-
const sourceInfo = getSourceInfoErrorAddendumForProps(config);
626-
if (sourceInfo) {
627-
info += sourceInfo;
628-
} else {
629-
info += getDeclarationErrorAddendum();
630-
}
631-
632618
let typeString;
633619
if (type === null) {
634620
typeString = 'null';
@@ -939,24 +925,6 @@ function getDeclarationErrorAddendum() {
939925
}
940926
}
941927

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-
960928
/**
961929
* Ensure that every element either is passed in a static location, in an
962930
* array with an explicit keys property defined, or in an object literal

0 commit comments

Comments
 (0)