-
-
Notifications
You must be signed in to change notification settings - Fork 344
[navigation menu] Mount content as hidden before hydration #3794
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: master
Are you sure you want to change the base?
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
eb4920e to
f87bf7e
Compare
Greptile SummaryThis PR adds server-side rendering support to
The implementation correctly avoids hydration mismatches by ensuring SSR and initial client render produce identical output. Confidence Score: 4/5
Important Files Changed
|
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.
2 files reviewed, 1 comment
| if (!selfMounted) { | ||
| return content; | ||
| } |
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.
logic: hydration mismatch will occur between SSR (renders content in-place with hidden) and client (returns null or portal). consider adding suppressHydrationWarning to parent to avoid React warnings.
| if (!selfMounted) { | |
| return content; | |
| } | |
| if (!selfMounted) { | |
| return <div suppressHydrationWarning>{content}</div>; | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react/src/navigation-menu/content/NavigationMenuContent.tsx
Line: 148:150
Comment:
**logic:** hydration mismatch will occur between SSR (renders content in-place with `hidden`) and client (returns null or portal). consider adding `suppressHydrationWarning` to parent to avoid React warnings.
```suggestion
if (!selfMounted) {
return <div suppressHydrationWarning>{content}</div>;
}
```
How can I resolve this? If you propose a fix, please make it concise.
Closes #3755
Before hydration, this renders the
<NavigationMenu.Content>into the DOM with ahiddenattribute. After hydration, it's removed from the DOM (and only then portaled into the popup element as normal)