Warn when <title> has invalid children on the client#36183
Open
Zelys-DFKH wants to merge 1 commit intofacebook:mainfrom
Open
Warn when <title> has invalid children on the client#36183Zelys-DFKH wants to merge 1 commit intofacebook:mainfrom
Zelys-DFKH wants to merge 1 commit intofacebook:mainfrom
Conversation
…33341) Moves the <title> children validation that existed only in the server renderer (ReactFizzConfigDOM) into a shared module (ReactDOMTitle) and calls it from the client renderer's validatePropertiesInDevelopment as well. Previously, passing multiple JSX children, a function, a symbol, or a plain object to <title> silently produced no output or wrong output on the client with no developer-facing warning. Now the same warnings that fire during SSR also fire during client-side rendering. Also fixes a typo in the original server-side message: "Sybmol" -> "Symbol".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
React has validated
<title>children on the server since #33349 was merged, but those same validations never ran on the client. A developer writing<title>Hello {name}</title>in JSX would see an empty<title>in the browser with no warning, while the SSR path correctly fired a diagnostic.This PR extracts the existing server-side validation into a shared module (
ReactDOMTitle.js) and wires it into the client renderer'svalidatePropertiesInDevelopment. The four validated cases are unchanged in behavior:$$typeof)toStringThe shared module also fixes a pre-existing typo in the server message:
"a Sybmol"becomes"a Symbol".Tests updated:
ReactDOMComponent-test.jscovering the array caseReactDOMFizzServer-test.jstests updated to assert that the same warning now also fires during client hydration (without a component stack, which is expected for the hoistable hydration path)Closes #33341