fix: suppress expected Background hydration mismatch, allow vercel.live CSP#93
Open
Samurai33 wants to merge 1 commit into
Open
fix: suppress expected Background hydration mismatch, allow vercel.live CSP#93Samurai33 wants to merge 1 commit into
Samurai33 wants to merge 1 commit into
Conversation
…ve in CSP Reported directly from the browser console on the live site: - "Uncaught Error: Minified React error #418" - Background.tsx's particle positions use Math.random() in a useState initializer that runs during both the server and client's shared render pass, so they necessarily differ. That's intentional (each pageview gets its own scatter), but without suppressHydrationWarning React treated the mismatch as an error instead of the expected divergence it is. Tried moving generation into a useEffect first, but that trips the React Compiler's react-hooks/set-state-in-effect lint rule (setState synchronously in an effect) - suppressHydrationWarning on the affected divs is the officially documented fix for exactly this "value legitimately differs per render" case and needs no lint exception. - CSP blocked https://vercel.live/_next-live/feedback/feedback.js - that's Vercel's Preview Comments/feedback toolbar, injected on preview (branch) deployments only. Added vercel.live to script-src/connect-src/frame-src. Verified with lint (0 errors) + type-check + test (27/27) + build.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Two issues reported directly from the live browser console:
Uncaught Error: Minified React error #418-Background.tsx's floating particles useMath.random()in auseStateinitializer, which runs during both server and client's shared render pass and necessarily produces different values (intentional - each pageview gets its own scatter). WithoutsuppressHydrationWarning, React treated the expected divergence as a hydration error. Tried deferring generation to auseEffectfirst, but that trips the React Compiler'sreact-hooks/set-state-in-effectrule -suppressHydrationWarningon the affected divs is the documented fix for exactly this case.vercel.live/_next-live/feedback/feedback.js- Vercel's Preview Comments toolbar, injected on preview deployments. Addedvercel.livetoscript-src/connect-src/frame-src.Test plan