fix(hydration): suppress React #418 errors from Nextra internals (SHA-2240)#209
Merged
Conversation
…-2240)
Three targeted fixes for latent React hydration mismatches that became
visible after the PostHog error handler was added (2026-05-04):
1. Add suppressHydrationWarning to <body> — guards against next-themes
writing data-theme to the body before React finishes reconciling;
without this, ThemeProvider's localStorage read produces a body-level
#418 on every cold page load.
2. Remove i18n prop from Layout — docs has a single locale (en). Passing
i18n caused the Nextra Switchers component to render LocaleSwitch in
the footer whenever hideSidebar=true (page-type routes), producing an
"HTML vs text" structural difference between SSR and client trees.
3. Filter React hydration errors in PostHog IGNORED_PATTERNS — the errors
predate the PostHog change; the new window.addEventListener('error')
handler just made them visible. Patterns: "Hydration failed",
"There was an error while hydrating", "Text content did not match".
Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
efedb77 to
ea67128
Compare
ea67128 to
79e6cef
Compare
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.
Summary
suppressHydrationWarningto<body>— guards againstnext-themeswritingdata-themefromlocalStoragebefore React reconciles; without this, ThemeProvider causes a body-level #418 on every cold page loadi18nprop fromLayout— docs has a single locale (en); the prop caused Nextra'sSwitcherscomponent to mountLocaleSwitchin the footer on page-type routes, producing an "HTML vs text" structural mismatch between SSR and client trees (confirmed absent from built output via$L1cmount reference check)IGNORED_PATTERNSwith React hydration error strings — defense-in-depth; the structural fixes are the real solution, but filtering prevents false-positive error tracking while residual instances fade post-deployBackground
A PostHog handler change deployed 2026-05-04 surfaced latent React #418 hydration errors (26+ in a partial day). The errors predate the handler change; the new
window.addEventListener('error')handler just made them visible.QA
LocaleSwitchmount reference (\$L1c) absent from renderedout/en/pricing.html→ i18n removal effective<body suppressHydrationWarning>andIGNORED_PATTERNSupdates verified in sourceCloses SHA-2240
🤖 Generated with Claude Code