You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue describes a common problem that has an easy but non-obvious solution.
Browsers interpret the contents of <title> as literal text.
React uses comments to mark the boundaries between static and dynamic content
Putting (1) and (2) together means that this normal-seeming JSX is broken:
<head><title>Some static text {aVariable} more static text</title></head>
react-dom emits a warning:
Warning: 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 the children being rendered output more than a single text node in aggregate the browser will display markup and comments as text in the title and hydration will likely fail and fall back to client rendering
I propose a rule that allows static text or an interpolation, but not both as the child of <title>.
Valid:
<title>Some static text</title>
Valid:
<title>{aVariable}</title>
Valid:
<title>{`A Template string {isAGreatWay} to combine them`}</title>
Invalid:
<title>Some static text {aVariable} more static text</title>
The text was updated successfully, but these errors were encountered:
tbh this seems like just a bug in React to me - i'm not sure why they can't just omit the comments for <title>, presumably at the insignificant cost of making updates to that element slower or more frequent.
This issue describes a common problem that has an easy but non-obvious solution.
<title>
as literal text.Putting (1) and (2) together means that this normal-seeming JSX is broken:
react-dom emits a warning:
I propose a rule that allows static text or an interpolation, but not both as the child of
<title>
.The text was updated successfully, but these errors were encountered: