-
-
Notifications
You must be signed in to change notification settings - Fork 531
Perf - Fixed the React "Hydration failed because the initial UI..." error on homepage #2568
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
base: testing
Are you sure you want to change the base?
Conversation
|
Warning Rate limit exceeded@zonetecde has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 52 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return ( | ||
| // eslint-disable-next-line jsx-a11y/no-static-element-interactions | ||
| <div | ||
| ref={cardRef} | ||
| role={link ? 'link' : undefined} | ||
| // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex | ||
| tabIndex={link ? 0 : undefined} | ||
| className={classNames( | ||
| styles.card, | ||
| className, | ||
| { [styles.cardWithLink]: Boolean(link) }, | ||
| link ? linkClassName : undefined, | ||
| )} | ||
| onClick={link ? handleCardClick : onClick} | ||
| onKeyDown={link ? handleCardKeyDown : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing anchor with div removes browser link affordances
The new card renders a div with role="link" and drives navigation via router.push/window.location instead of the previous <Link> wrapper. While this prevents the hydration warning, it removes native link semantics: users can no longer open the card in a new tab with middle‑click or Cmd/Ctrl‑click, there is no context‑menu “open link” option, and Next.js’ Link prefetching is lost. These regressions affect accessibility and performance for every card rendered with a link prop.
Useful? React with 👍 / 👎.
Summary
The mismatch forced React to discard the server DOM and rebuild it on the client, slightly impacting Performance/Best Practices scores on slower devices.
The shared Card component now renders a single focusable container instead of a nested div inside the link, which previously caused the hydration error.
Note: only for non-logged-in users
Type of change
Test plan
Verified that the card still works as expected and that the hydration error no longer appears.
Checklist
Screenshots or videos
Summary by CodeRabbit