Fix suppressHydrationWarning not working in production#24271
Merged
gaearon merged 1 commit intofacebook:mainfrom Apr 4, 2022
Merged
Fix suppressHydrationWarning not working in production#24271gaearon merged 1 commit intofacebook:mainfrom
gaearon merged 1 commit intofacebook:mainfrom
Conversation
gaearon
commented
Apr 4, 2022
| let extraAttributeNames: Set<string>; | ||
|
|
||
| if (__DEV__) { | ||
| suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; |
Collaborator
Author
There was a problem hiding this comment.
Moved inline since we don't want to hit the property checks for every props object.
gaearon
commented
Apr 4, 2022
| ? null | ||
| : getPropertyInfo(propKey); | ||
| if (suppressHydrationWarning) { | ||
| if (rawProps[SUPPRESS_HYDRATION_WARNING] === true) { |
Collaborator
Author
There was a problem hiding this comment.
This runs repeatedly but this part is DEV-only.
gaearon
commented
Apr 4, 2022
|
|
||
| let SUPPRESS_HYDRATION_WARNING; | ||
| if (__DEV__) { | ||
| SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; |
Collaborator
Author
There was a problem hiding this comment.
I've added a regression test for this one as well.
|
Comparing: c89a15c...98de7f6 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
1786a32 to
98de7f6
Compare
acdlite
approved these changes
Apr 4, 2022
Collaborator
acdlite
left a comment
There was a problem hiding this comment.
Looks good to me though I'm not super familiar with this code path so not sure if there are other implications
sebmarkbage
approved these changes
Apr 4, 2022
rickhanlonii
pushed a commit
that referenced
this pull request
Apr 13, 2022
rickhanlonii
pushed a commit
that referenced
this pull request
Apr 14, 2022
zhengjitf
pushed a commit
to zhengjitf/react
that referenced
this pull request
Apr 15, 2022
This was referenced Mar 4, 2023
This was referenced Feb 10, 2024
This was referenced Nov 8, 2024
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.
Fixes #24270.
We intended
suppressHydrationWarningto be checked in production as an escape hatch in 18 and prevent mismatch errors. However, the logic mistakingly only read it in development mode. I've added regression tests for the lines I've changed.I've noticed we don't patch up
dangerouslySetInnerHTMLlike we do text content. (Although we do ignore its mismatch in production.) I left that as is, but added a test verifying the current behavior.