Skip to content

Commit

Permalink
fixup dev warning conditional logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Jun 7, 2022
1 parent 125ec3a commit 1ea51af
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Expand Up @@ -1157,8 +1157,7 @@ function pushStartTitle(
Array.isArray(children) && children.length < 2
? children[0] || null
: children;
if (Array.isArray(child)) {
// child will only be an Array if it has lenght > 1 based on how it was constructed
if (Array.isArray(children) && children.length > 1) {
console.error(
'A title element received an array with more than 1 element as children. ' +
'In browsers title Elements can only have Text Nodes as children. If ' +
Expand All @@ -1174,7 +1173,11 @@ function pushStartTitle(
'will display markup and comments as text in the title and hydration will likely fail and ' +
'fall back to client rendering',
);
} else if (typeof child !== 'string' && typeof child !== 'number') {
} else if (
child != null &&
typeof child !== 'string' &&
typeof child !== 'number'
) {
console.error(
'A title element received a value that was not a string or number for children. ' +
'In the browser title Elements can only have Text Nodes as children. If ' +
Expand Down

0 comments on commit 1ea51af

Please sign in to comment.