Skip to content

Commit b300304

Browse files
Update error decoder URL (#27240)
Updates the error decoder to the URL for the new docs site. - Switches the domain from reactjs.org to react.dev - Switches to put the error code in the URL for SSG - All params are still in the query Example without args: - Before: `https://reactjs.org/docs/error-decoder.html?invariant=200` - After: ` https://react.dev/errors/200` Example with args: - Before: `https://reactjs.org/docs/error-decoder.html?invariant=124?args[]=foo&args[]=bar ` - After: ` https://react.dev/errors/124?args[]=foo&args[]=bar` Requires: reactjs/react.dev#6214 --------- Co-authored-by: Jan Kassens <jkassens@meta.com>
1 parent 5c60736 commit b300304

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

packages/shared/__tests__/ReactError-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('ReactError', () => {
4141
it('should error with minified error code', () => {
4242
expect(() => ReactDOM.render('Hi', null)).toThrowError(
4343
'Minified React error #200; visit ' +
44-
'https://reactjs.org/docs/error-decoder.html?invariant=200' +
44+
'https://react.dev/errors/200' +
4545
' for the full message or use the non-minified dev environment' +
4646
' for full errors and additional helpful warnings.',
4747
);

packages/shared/__tests__/ReactErrorProd-test.internal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ describe('ReactErrorProd', () => {
1919
it('should throw with the correct number of `%s`s in the URL', () => {
2020
expect(formatProdErrorMessage(124, 'foo', 'bar')).toEqual(
2121
'Minified React error #124; visit ' +
22-
'https://reactjs.org/docs/error-decoder.html?invariant=124&args[]=foo&args[]=bar' +
22+
'https://react.dev/errors/124?args[]=foo&args[]=bar' +
2323
' for the full message or use the non-minified dev environment' +
2424
' for full errors and additional helpful warnings.',
2525
);
2626

2727
expect(formatProdErrorMessage(20)).toEqual(
2828
'Minified React error #20; visit ' +
29-
'https://reactjs.org/docs/error-decoder.html?invariant=20' +
29+
'https://react.dev/errors/20' +
3030
' for the full message or use the non-minified dev environment' +
3131
' for full errors and additional helpful warnings.',
3232
);
3333

3434
expect(formatProdErrorMessage(77, '<div>', '&?bar')).toEqual(
3535
'Minified React error #77; visit ' +
36-
'https://reactjs.org/docs/error-decoder.html?invariant=77&args[]=%3Cdiv%3E&args[]=%26%3Fbar' +
36+
'https://react.dev/errors/77?args[]=%3Cdiv%3E&args[]=%26%3Fbar' +
3737
' for the full message or use the non-minified dev environment' +
3838
' for full errors and additional helpful warnings.',
3939
);

packages/shared/formatProdErrorMessage.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
// during build.
1212

1313
function formatProdErrorMessage(code) {
14-
let url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code;
15-
for (let i = 1; i < arguments.length; i++) {
16-
url += '&args[]=' + encodeURIComponent(arguments[i]);
14+
let url = 'https://react.dev/errors/' + code;
15+
if (arguments.length > 1) {
16+
url += '?args[]=' + encodeURIComponent(arguments[1]);
17+
for (let i = 2; i < arguments.length; i++) {
18+
url += '&args[]=' + encodeURIComponent(arguments[i]);
19+
}
1720
}
21+
1822
return (
1923
`Minified React error #${code}; visit ${url} for the full message or ` +
2024
'use the non-minified dev environment for full errors and additional ' +

scripts/jest/setupTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
169169
if (!message) {
170170
return message;
171171
}
172-
const re = /error-decoder.html\?invariant=(\d+)([^\s]*)/;
172+
const re = /react.dev\/errors\/(\d+)?\??([^\s]*)/;
173173
const matches = message.match(re);
174174
if (!matches || matches.length !== 3) {
175175
return message;

0 commit comments

Comments
 (0)