Skip to content

Commit d97aacc

Browse files
committed
fix bugs
1 parent 1810bd5 commit d97aacc

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4537,11 +4537,15 @@ describe('ReactDOMFizzServer', () => {
45374537
},
45384538
});
45394539
expect(Scheduler).toFlushAndYield([]);
4540-
expect(errors).toEqual([
4541-
'Text content does not match server-rendered HTML.',
4542-
'Hydration failed because the initial UI does not match what was rendered on the server.',
4543-
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
4544-
]);
4540+
expect(errors).toEqual(
4541+
[
4542+
gate(flags => flags.enableClientRenderFallbackOnTextMismatch)
4543+
? 'Text content does not match server-rendered HTML.'
4544+
: null,
4545+
'Hydration failed because the initial UI does not match what was rendered on the server.',
4546+
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
4547+
].filter(Boolean),
4548+
);
45454549
expect(getVisibleChildren(container)).toEqual(
45464550
<title>{['hello1', 'hello2']}</title>,
45474551
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ function pushStartTitle(
11641164
'will display markup and comments as text in the title and hydration will likely fail and ' +
11651165
'fall back to client rendering',
11661166
);
1167-
} else if (child.$$typeof != null) {
1167+
} else if (child != null && child.$$typeof != null) {
11681168
console.error(
11691169
'A title element received a React element for children. ' +
11701170
'In the browser title Elements can only have Text Nodes as children. If ' +

0 commit comments

Comments
 (0)