nextui
nextui copied to clipboard
[BUG] - Hydration error with Navbar
HeroUI Version
2.7.4
Describe the bug
Error: Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:
- A server/client branch
if (typeof window !== 'undefined'). - Variable input such as
Date.now()orMath.random()which changes each time it's called. - Date formatting in a user's locale which doesn't match the server.
- External changing data without sending a snapshot of it along with the HTML.
- Invalid HTML tag nesting.
It can also happen if the client has a browser extension installed which messes with the HTML before React loaded.
https://react.dev/link/hydration-mismatch
...
<HeroUIProvider locale="pt-BR" suppressHydrationWarning={true}>
<$18f2051aff69b9bf$export$a54013f0d02a8f82 locale="pt-BR">
<MotionConfig reducedMotion="never">
<$f57aed4a881a3485$export$bf688221f59024e5 suppressHydrationWarning={true}>
<$f57aed4a881a3485$export$178405afcd8c5eb>
<$f57aed4a881a3485$var$OverlayContainerDOM suppressHydrationWarning={true}>
<div data-overlay-container={true} suppressHydrationWarning={true} aria-hidden={undefined}>
<Navbar>
<HeroUI.Navbar isBordered={true} isBlurred={true} onMenuOpenChange={function bound dispatchSetState} ...>
+ <nav
+ data-hidden={undefined}
+ data-menu-open={undefined}
+ ref={{current:null}}
+ className="flex z-40 w-full h-auto items-center justify-center data-[menu-open=true]:border-no..."
+ style={{--navbar-height:"4rem"}}
+ >
...
at throwOnHydrationMismatch (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:13311:11)
at beginWork (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:10194:17)
at runWithFiberInDEV (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:1511:30)
at performUnitOfWork (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:15116:22)
at workLoopConcurrentByScheduler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:15110:9)
at renderRootConcurrent (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:15085:15)
at performWorkOnRoot (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:14406:13)
at performWorkOnRootViaSchedulerTask (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom-client.development.js:16272:7)
at MessagePort.performWorkUntilDeadline (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js:45:48)
at nav (<anonymous>)
at HeroUI.Navbar (webpack-internal:///(app-pages-browser)/./node_modules/@heroui/navbar/dist/chunk-63OA3RRZ.mjs:56:84)
at Navbar (webpack-internal:///(app-pages-browser)/./src/components/ui/Navbar/index.tsx:437:90)
at RootLayout (rsc://React/Server/webpack-internal:///(rsc)/./src/app/layout.tsx?1:69:96)
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Just do F5 in any page and get this error.
Expected behavior
As a user, I expect heroui to be compatible with SSR.
Screenshots or Videos
Operating System Version
Windows 11
Browser
Chrome
please provide a minimal reproducible environment.