Skip to content

Commit 323b6e9

Browse files
authored
Remove errorHydratingContainer (#28664)
I originally added this in #21021 but I didn't mention why and I don't quite remember why. Maybe because there were no other message? However at the time the recoverable errors mechanism didn't exist. Today I believe all cases where this happens will trigger another recoverable error. Namely these two: https://github.com/facebook/react/blob/9f33f699e4f832971dc0f2047129f832655a3b6d/packages/react-reconciler/src/ReactFiberBeginWork.js#L1442-L1446 https://github.com/facebook/react/blob/9f33f699e4f832971dc0f2047129f832655a3b6d/packages/react-reconciler/src/ReactFiberBeginWork.js#L2962-L2965 Therefore this is just an extra unnecessary log.
1 parent 9f33f69 commit 323b6e9

15 files changed

+150
-370
lines changed

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

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,19 +2406,12 @@ describe('ReactDOMFizzServer', () => {
24062406
},
24072407
});
24082408

2409-
await expect(async () => {
2410-
// The first paint switches to client rendering due to mismatch
2411-
await waitForPaint([
2412-
'client',
2413-
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
2414-
'Log recoverable error: There was an error while hydrating.',
2415-
]);
2416-
}).toErrorDev(
2417-
[
2418-
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
2419-
],
2420-
{withoutStack: 1},
2421-
);
2409+
// The first paint switches to client rendering due to mismatch
2410+
await waitForPaint([
2411+
'client',
2412+
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
2413+
'Log recoverable error: There was an error while hydrating.',
2414+
]);
24222415
expect(getVisibleChildren(container)).toEqual(<div>client</div>);
24232416
});
24242417

@@ -2486,19 +2479,12 @@ describe('ReactDOMFizzServer', () => {
24862479
});
24872480

24882481
// The first paint uses the client due to mismatch forcing client render
2489-
await expect(async () => {
2490-
// The first paint switches to client rendering due to mismatch
2491-
await waitForPaint([
2492-
'client',
2493-
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
2494-
'Log recoverable error: There was an error while hydrating.',
2495-
]);
2496-
}).toErrorDev(
2497-
[
2498-
'Warning: An error occurred during hydration. The server HTML was replaced with client content',
2499-
],
2500-
{withoutStack: 1},
2501-
);
2482+
// The first paint switches to client rendering due to mismatch
2483+
await waitForPaint([
2484+
'client',
2485+
"Log recoverable error: Hydration failed because the server rendered HTML didn't match the client.",
2486+
'Log recoverable error: There was an error while hydrating.',
2487+
]);
25022488
expect(getVisibleChildren(container)).toEqual(<div>client</div>);
25032489
});
25042490

@@ -2564,16 +2550,11 @@ describe('ReactDOMFizzServer', () => {
25642550

25652551
// An error logged but instead of surfacing it to the UI, we switched
25662552
// to client rendering.
2567-
await expect(async () => {
2568-
await waitForAll([
2569-
'Yay!',
2570-
'Hydration error',
2571-
'There was an error while hydrating.',
2572-
]);
2573-
}).toErrorDev(
2574-
'An error occurred during hydration. The server HTML was replaced',
2575-
{withoutStack: true},
2576-
);
2553+
await waitForAll([
2554+
'Yay!',
2555+
'Hydration error',
2556+
'There was an error while hydrating.',
2557+
]);
25772558
expect(getVisibleChildren(container)).toEqual(<span>Yay!</span>);
25782559

25792560
// The node that's inside the boundary that errored during hydration was
@@ -6339,9 +6320,7 @@ describe('ReactDOMFizzServer', () => {
63396320
errors.push(error);
63406321
},
63416322
});
6342-
await expect(async () => {
6343-
await waitForAll([]);
6344-
}).toErrorDev(['An error occurred during hydration'], {withoutStack: 1});
6323+
await waitForAll([]);
63456324
expect(errors.length).toEqual(2);
63466325
expect(getVisibleChildren(container)).toEqual(<span />);
63476326
});

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

Lines changed: 28 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
249249
Scheduler.log(normalizeError(error.message));
250250
},
251251
});
252-
await expect(async () => {
253-
await waitForAll([
254-
"Hydration failed because the server rendered HTML didn't match the client.",
255-
'There was an error while hydrating.',
256-
]);
257-
}).toErrorDev(
258-
[
259-
'An error occurred during hydration. The server HTML was replaced with client content.',
260-
],
261-
{withoutStack: 1},
262-
);
252+
await waitForAll([
253+
"Hydration failed because the server rendered HTML didn't match the client.",
254+
'There was an error while hydrating.',
255+
]);
263256
expect(getVisibleChildren(container)).toEqual(
264257
<div>
265258
<span>
@@ -337,17 +330,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
337330
Scheduler.log(normalizeError(error.message));
338331
},
339332
});
340-
await expect(async () => {
341-
await waitForAll([
342-
"Hydration failed because the server rendered HTML didn't match the client.",
343-
'There was an error while hydrating.',
344-
]);
345-
}).toErrorDev(
346-
[
347-
'An error occurred during hydration. The server HTML was replaced with client content.',
348-
],
349-
{withoutStack: 1},
350-
);
333+
await waitForAll([
334+
"Hydration failed because the server rendered HTML didn't match the client.",
335+
'There was an error while hydrating.',
336+
]);
351337
expect(getVisibleChildren(container)).toEqual(
352338
<div>
353339
<span />
@@ -384,17 +370,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
384370
Scheduler.log(normalizeError(error.message));
385371
},
386372
});
387-
await expect(async () => {
388-
await waitForAll([
389-
"Hydration failed because the server rendered HTML didn't match the client.",
390-
'There was an error while hydrating.',
391-
]);
392-
}).toErrorDev(
393-
[
394-
'An error occurred during hydration. The server HTML was replaced with client content.',
395-
],
396-
{withoutStack: 1},
397-
);
373+
await waitForAll([
374+
"Hydration failed because the server rendered HTML didn't match the client.",
375+
'There was an error while hydrating.',
376+
]);
398377
expect(getVisibleChildren(container)).toEqual(
399378
<div>
400379
<span>
@@ -434,17 +413,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
434413
Scheduler.log(normalizeError(error.message));
435414
},
436415
});
437-
await expect(async () => {
438-
await waitForAll([
439-
"Hydration failed because the server rendered HTML didn't match the client.",
440-
'There was an error while hydrating.',
441-
]);
442-
}).toErrorDev(
443-
[
444-
'An error occurred during hydration. The server HTML was replaced with client content.',
445-
],
446-
{withoutStack: 1},
447-
);
416+
await waitForAll([
417+
"Hydration failed because the server rendered HTML didn't match the client.",
418+
'There was an error while hydrating.',
419+
]);
448420
expect(getVisibleChildren(container)).toEqual(
449421
<div>
450422
<span>
@@ -482,17 +454,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
482454
Scheduler.log(normalizeError(error.message));
483455
},
484456
});
485-
await expect(async () => {
486-
await waitForAll([
487-
"Hydration failed because the server rendered HTML didn't match the client.",
488-
'There was an error while hydrating.',
489-
]);
490-
}).toErrorDev(
491-
[
492-
'An error occurred during hydration. The server HTML was replaced with client content.',
493-
],
494-
{withoutStack: 1},
495-
);
457+
await waitForAll([
458+
"Hydration failed because the server rendered HTML didn't match the client.",
459+
'There was an error while hydrating.',
460+
]);
496461
expect(getVisibleChildren(container)).toEqual(
497462
<div>
498463
<span>
@@ -604,17 +569,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
604569
Scheduler.log(normalizeError(error.message));
605570
},
606571
});
607-
await expect(async () => {
608-
await waitForAll([
609-
"Hydration failed because the server rendered HTML didn't match the client.",
610-
'There was an error while hydrating.',
611-
]);
612-
}).toErrorDev(
613-
[
614-
'An error occurred during hydration. The server HTML was replaced with client content.',
615-
],
616-
{withoutStack: 1},
617-
);
572+
await waitForAll([
573+
"Hydration failed because the server rendered HTML didn't match the client.",
574+
'There was an error while hydrating.',
575+
]);
618576
expect(getVisibleChildren(container)).toEqual(
619577
<div>
620578
<p>Client and server</p>
@@ -649,17 +607,10 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
649607
Scheduler.log(normalizeError(error.message));
650608
},
651609
});
652-
await expect(async () => {
653-
await waitForAll([
654-
"Hydration failed because the server rendered HTML didn't match the client.",
655-
'There was an error while hydrating.',
656-
]);
657-
}).toErrorDev(
658-
[
659-
'An error occurred during hydration. The server HTML was replaced with client content.',
660-
],
661-
{withoutStack: 1},
662-
);
610+
await waitForAll([
611+
"Hydration failed because the server rendered HTML didn't match the client.",
612+
'There was an error while hydrating.',
613+
]);
663614
expect(getVisibleChildren(container)).toEqual(
664615
<div>
665616
<p>Client and server</p>

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6477,14 +6477,7 @@ body {
64776477
},
64786478
},
64796479
);
6480-
await expect(async () => {
6481-
await waitForAll([]);
6482-
}).toErrorDev(
6483-
[
6484-
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
6485-
],
6486-
{withoutStack: 1},
6487-
);
6480+
await waitForAll([]);
64886481
expect(getMeaningfulChildren(document)).toEqual(
64896482
<html>
64906483
<head>
@@ -8267,14 +8260,7 @@ background-color: green;
82678260
},
82688261
);
82698262

8270-
await expect(async () => {
8271-
await waitForAll([]);
8272-
}).toErrorDev(
8273-
[
8274-
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
8275-
],
8276-
{withoutStack: 1},
8277-
);
8263+
await waitForAll([]);
82788264
expect(getMeaningfulChildren(document)).toEqual(
82798265
<html>
82808266
<head>

0 commit comments

Comments
 (0)