Skip to content

Commit 27535e7

Browse files
wherestheguacgaearon
authored andcommitted
Clarify ReactDOM's case warning for html tags (#12533)
* update warning text * update tests to match * `yarn prettier` * include note on HTML5 custom elements * dan’s copy suggestion * remove ‘letters’
1 parent 8ec0e4a commit 27535e7

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

packages/react-dom/src/__tests__/ReactDOMComponent-test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,11 @@ describe('ReactDOMComponent', () => {
10001000

10011001
expect(() => {
10021002
returnedValue = ReactDOMServer.renderToString(<Container />);
1003-
}).toWarnDev('<BR /> is using uppercase HTML.');
1003+
}).toWarnDev(
1004+
'<BR /> is using incorrect casing. ' +
1005+
'Use PascalCase for React components, ' +
1006+
'or lowercase for HTML elements.',
1007+
);
10041008
expect(returnedValue).not.toContain('</BR>');
10051009
});
10061010

@@ -1012,7 +1016,11 @@ describe('ReactDOMComponent', () => {
10121016

10131017
expect(() =>
10141018
ReactTestUtils.renderIntoDocument(React.createElement('IMG')),
1015-
).toWarnDev('<IMG /> is using uppercase HTML.');
1019+
).toWarnDev(
1020+
'<IMG /> is using incorrect casing. ' +
1021+
'Use PascalCase for React components, ' +
1022+
'or lowercase for HTML elements.',
1023+
);
10161024
});
10171025

10181026
it('should warn on props reserved for future use', () => {
@@ -1059,7 +1067,9 @@ describe('ReactDOMComponent', () => {
10591067
expect(() =>
10601068
ReactTestUtils.renderIntoDocument(<hasOwnProperty />),
10611069
).toWarnDev([
1062-
'<hasOwnProperty /> is using uppercase HTML',
1070+
'<hasOwnProperty /> is using incorrect casing. ' +
1071+
'Use PascalCase for React components, ' +
1072+
'or lowercase for HTML elements.',
10631073
'The tag <hasOwnProperty> is unrecognized in this browser',
10641074
]);
10651075
} finally {

packages/react-dom/src/__tests__/ReactServerRendering-test.internal.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,13 @@ describe('ReactDOMServer', () => {
602602
</div>,
603603
),
604604
).toWarnDev([
605-
'Warning: <inPUT /> is using uppercase HTML. Always use lowercase ' +
606-
'HTML tags in React.',
605+
'Warning: <inPUT /> is using incorrect casing. ' +
606+
'Use PascalCase for React components, ' +
607+
'or lowercase for HTML elements.',
607608
// linearGradient doesn't warn
608-
'Warning: <iFrame /> is using uppercase HTML. Always use lowercase ' +
609-
'HTML tags in React.',
609+
'Warning: <iFrame /> is using incorrect casing. ' +
610+
'Use PascalCase for React components, ' +
611+
'or lowercase for HTML elements.',
610612
]);
611613
});
612614

packages/react-dom/src/client/ReactDOMFiberComponent.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,9 @@ export function createElement(
355355
// allow <SVG> or <mATH>.
356356
warning(
357357
isCustomComponentTag || type === type.toLowerCase(),
358-
'<%s /> is using uppercase HTML. Always use lowercase HTML tags ' +
359-
'in React.',
358+
'<%s /> is using incorrect casing. ' +
359+
'Use PascalCase for React components, ' +
360+
'or lowercase for HTML elements.',
360361
type,
361362
);
362363
}

packages/react-dom/src/server/ReactPartialRenderer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,9 @@ class ReactDOMServerRenderer {
955955
// allow <SVG> or <mATH>.
956956
warning(
957957
tag === element.type,
958-
'<%s /> is using uppercase HTML. Always use lowercase HTML tags ' +
959-
'in React.',
958+
'<%s /> is using incorrect casing. ' +
959+
'Use PascalCase for React components, ' +
960+
'or lowercase for HTML elements.',
960961
element.type,
961962
);
962963
}

0 commit comments

Comments
 (0)