-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppress Safari class name mismatch warning #2569
Conversation
🦋 Changeset detectedLatest commit: e9ccdca The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e9ccdca:
|
Codecov Report
|
packages/react/__tests__/suppress-safari-class-name-mismatch.js
Outdated
Show resolved
Hide resolved
packages/react/__tests__/suppress-safari-class-name-mismatch.js
Outdated
Show resolved
Hide resolved
- Fix bug: not handling non-Emotion class names - Implement Andarist's suggestions
Thanks for the feedback @Andarist. I addressed all but one comment which I replied to. |
Edit: Nevermind, I think I know how to solve this. @Andarist @mitchellhamilton Hey, I made some progress on this but I have hit a snag. Case 1There are two caches, one with key
The hydration warning is caused by failed runtime label extraction and should be suppressed. Case 2
The hydration warning is caused by failed runtime label extraction AND a legit class name mismatch and therefore should not be suppressed. ProblemMy code should behave differently in Case 1 and Case 2. But how can I differentiate between them while only knowing about one Emotion cache at a time? |
Sigh... This is done except for testing in IE, but I realized a major shortcoming of suppressing hydration warnings by overriding Here is what I believe is a common situation: render(
<div>
<ComponentForWhichRuntimeLabelExtractionFails />
<ComponentThatRendersDifferentContentOnServerVersusBrowser />
</div>
) In this case, the second component causes a hydration warning that must be presented to the user. We would be good if React called It seems like this completely invalidates the approach of overriding |
Following up on my previous comment, the best option I can think of now is to make runtime label extraction an optional feature. You could pass a
Questions
|
What: As discussed in #2534, runtime label extraction may fail in Safari due to Proper Tail Calls. This can result in hydration errors in development when using SSR and Safari.
Closes #2255.
Why: To shield innocent users from a confusing warning message.
How:
console.error
in Safari only and suppress class name mismatch warnings that are likely the result of failed label extraction.console.error
is not overridden in Node.Checklist:
Original Suggestion
This was originally proposed by @mitchellhamilton:
Unfortunately it is not possible to implement it like this because serialized styles are not always stored in
cache.registered
. See the insertStyles function.