Layout using Rootlayout
Unanswered
Basset Hound posted this in #help-forum
Basset HoundOP
I want to make a layout for a set of pages, take the Navbar of the root layout.
I tried this:
Unhandled Runtime Error
Error: Hydration failed because the initial UI does not match what was rendered on the server.
Warning: Expected server HTML to contain a matching <div> in <div>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
Component Stack
div
div
It works when I do, but then I dont have the RootLayout:
I tried this:
import RootLayout from '@/app/layout';
export default function TestLayout({
children,
}: {
children: React.ReactNode;
}) {
return <RootLayout>{children}</RootLayout>;
} but I get the following hydration errorUnhandled Runtime Error
Error: Hydration failed because the initial UI does not match what was rendered on the server.
Warning: Expected server HTML to contain a matching <div> in <div>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
Component Stack
div
div
It works when I do, but then I dont have the RootLayout:
export default function TestLayout({
children,
}: {
children: React.ReactNode;
}) {
return <>{children}</>;
}2 Replies
Bigheaded ant
👋 @Basset Hound
If your test layout is used in a child route, that means your root layout is already rendered anyway right? why do you need to include it inside a child layout?
since it's the root layout we're talking about here, it most likely include html, head and body tags, nested html tags would most likely produce those kind of hydration errors
If your test layout is used in a child route, that means your root layout is already rendered anyway right? why do you need to include it inside a child layout?
since it's the root layout we're talking about here, it most likely include html, head and body tags, nested html tags would most likely produce those kind of hydration errors