Fix Hydration Mismatch in OrbVisualizer Component (Closes #111)#117
Closed
vedhapprakashni wants to merge 3 commits intoNitya-003:mainfrom
Closed
Fix Hydration Mismatch in OrbVisualizer Component (Closes #111)#117vedhapprakashni wants to merge 3 commits intoNitya-003:mainfrom
vedhapprakashni wants to merge 3 commits intoNitya-003:mainfrom
Conversation
|
@vedhapprakashni is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel. A member of the Team first needs to authorize it. |
…sing dependencies
6cbea11 to
f626cd7
Compare
9d10952 to
88a33fb
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.
Description
This PR fixes a critical hydration mismatch issue in the
OrbVisualizer
component caused by Math.random() calls during render.
Problem
The previous implementation used Math.random() directly in the render logic to generate particle positions and animation durations. This caused the server-rendered HTML to differ from the client-initial render, leading to Next.js hydration errors and broken animations.
Solution
Moved all random number generation into a useEffect hook to ensure it only runs on the client after mount.
Used state to store the generated random values.
Updated the component to render based on the state values.
Testing
Verify that the console no longer shows hydration mismatch warnings.
Confirm that the OrbVisualizer animation plays correctly after page load.