Skip to content

Commit 029e8bd

Browse files
authored
Add Owner Stack to attribute hydration mismatches (#32538)
1 parent e81fcfe commit 029e8bd

8 files changed

+444
-228
lines changed

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

+51-53
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,24 @@ describe('ReactDOMFizzForm', () => {
201201
await act(async () => {
202202
ReactDOMClient.hydrateRoot(container, <App isClient={true} />);
203203
});
204-
assertConsoleErrorDev(
205-
[
206-
"A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. " +
207-
"This won't be patched up. This can happen if a SSR-ed Client Component used:\n\n" +
208-
"- A server/client branch `if (typeof window !== 'undefined')`.\n" +
209-
"- Variable input such as `Date.now()` or `Math.random()` which changes each time it's called.\n" +
210-
"- Date formatting in a user's locale which doesn't match the server.\n" +
211-
'- External changing data without sending a snapshot of it along with the HTML.\n' +
212-
'- Invalid HTML tag nesting.\n\n' +
213-
'It can also happen if the client has a browser extension installed which messes with the HTML before React loaded.\n\n' +
214-
'https://react.dev/link/hydration-mismatch\n\n' +
215-
' <App isClient={true}>\n' +
216-
' <form\n' +
217-
'+ action="action"\n' +
218-
'- action="function"\n' +
219-
' >\n',
220-
],
221-
{withoutStack: true},
222-
);
204+
assertConsoleErrorDev([
205+
"A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. " +
206+
"This won't be patched up. This can happen if a SSR-ed Client Component used:\n\n" +
207+
"- A server/client branch `if (typeof window !== 'undefined')`.\n" +
208+
"- Variable input such as `Date.now()` or `Math.random()` which changes each time it's called.\n" +
209+
"- Date formatting in a user's locale which doesn't match the server.\n" +
210+
'- External changing data without sending a snapshot of it along with the HTML.\n' +
211+
'- Invalid HTML tag nesting.\n\n' +
212+
'It can also happen if the client has a browser extension installed which messes with the HTML before React loaded.\n\n' +
213+
'https://react.dev/link/hydration-mismatch\n\n' +
214+
' <App isClient={true}>\n' +
215+
' <form\n' +
216+
'+ action="action"\n' +
217+
'- action="function"\n' +
218+
' >\n' +
219+
'\n in form (at **)' +
220+
'\n in App (at **)',
221+
]);
223222
});
224223

225224
it('should ideally warn when passing a string during SSR and function during hydration', async () => {
@@ -392,40 +391,39 @@ describe('ReactDOMFizzForm', () => {
392391
await act(async () => {
393392
root = ReactDOMClient.hydrateRoot(container, <App />);
394393
});
395-
assertConsoleErrorDev(
396-
[
397-
"A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. " +
398-
"This won't be patched up. This can happen if a SSR-ed Client Component used:\n\n" +
399-
"- A server/client branch `if (typeof window !== 'undefined')`.\n" +
400-
"- Variable input such as `Date.now()` or `Math.random()` which changes each time it's called.\n" +
401-
"- Date formatting in a user's locale which doesn't match the server.\n" +
402-
'- External changing data without sending a snapshot of it along with the HTML.\n' +
403-
'- Invalid HTML tag nesting.\n\n' +
404-
'It can also happen if the client has a browser extension installed which messes with the HTML before React loaded.\n\n' +
405-
'https://react.dev/link/hydration-mismatch\n\n' +
406-
' <App>\n' +
407-
' <form\n' +
408-
' action={function action}\n' +
409-
' ref={{current:null}}\n' +
410-
'+ method="DELETE"\n' +
411-
'- method={null}\n' +
412-
' >\n' +
413-
' <input\n' +
414-
' type="submit"\n' +
415-
' formAction={function action}\n' +
416-
' ref={{current:null}}\n' +
417-
'+ formTarget="elsewhere"\n' +
418-
'- formTarget={null}\n' +
419-
' >\n' +
420-
' <button\n' +
421-
' formAction={function action}\n' +
422-
' ref={{current:null}}\n' +
423-
'+ formEncType="text/plain"\n' +
424-
'- formEncType={null}\n' +
425-
' >\n',
426-
],
427-
{withoutStack: true},
428-
);
394+
assertConsoleErrorDev([
395+
"A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. " +
396+
"This won't be patched up. This can happen if a SSR-ed Client Component used:\n\n" +
397+
"- A server/client branch `if (typeof window !== 'undefined')`.\n" +
398+
"- Variable input such as `Date.now()` or `Math.random()` which changes each time it's called.\n" +
399+
"- Date formatting in a user's locale which doesn't match the server.\n" +
400+
'- External changing data without sending a snapshot of it along with the HTML.\n' +
401+
'- Invalid HTML tag nesting.\n\n' +
402+
'It can also happen if the client has a browser extension installed which messes with the HTML before React loaded.\n\n' +
403+
'https://react.dev/link/hydration-mismatch\n\n' +
404+
' <App>\n' +
405+
' <form\n' +
406+
' action={function action}\n' +
407+
' ref={{current:null}}\n' +
408+
'+ method="DELETE"\n' +
409+
'- method={null}\n' +
410+
' >\n' +
411+
' <input\n' +
412+
' type="submit"\n' +
413+
' formAction={function action}\n' +
414+
' ref={{current:null}}\n' +
415+
'+ formTarget="elsewhere"\n' +
416+
'- formTarget={null}\n' +
417+
' >\n' +
418+
' <button\n' +
419+
' formAction={function action}\n' +
420+
' ref={{current:null}}\n' +
421+
'+ formEncType="text/plain"\n' +
422+
'- formEncType={null}\n' +
423+
' >\n' +
424+
'\n in input (at **)' +
425+
'\n in App (at **)',
426+
]);
429427
await act(async () => {
430428
root.render(<App isUpdate={true} />);
431429
});

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10233,7 +10233,7 @@ describe('ReactDOMFizzServer', () => {
1023310233
'\n+ client' +
1023410234
'\n- server' +
1023510235
'\n' +
10236-
'\n in Suspense (at **)' +
10236+
'\n in meta (at **)' +
1023710237
'\n in ClientApp (at **)',
1023810238
]);
1023910239
}

0 commit comments

Comments
 (0)