RootLayout confusion
Answered
Whimbrel posted this in #help-forum
WhimbrelOP
This code prints the Footer component twice.
Can someone explain why?
Can someone explain why?
import {theme} from "../styles/styles.css" import {Footer} from './components/interload' export default function RootLayout({ children }) { return (
<html lang="en" className="theme"> <head>
<title>title name</title>
</head>
<body>
{children}
<Footer />
</body>
</html>
)
}12 Replies
What is the URL you accesed
What is your route structure around the RootLayout
WhimbrelOP
This is the page.js
import {
PopoverDemo, MyBio,
Hobby,
Navbar, Footer,
} from './components/interload';
import RootLayout from './layout'
export default function Page() { return (
<RootLayout>
<Navbar />
<PopoverDemo />
<MyBio />
<Hobby />
</RootLayout>
)
}@alfon What is the URL you accesed
WhimbrelOP
The home page
This is footer.js
export function Footer(){
return (
<>
<footer>
<p>© 2023 Your name. All rights reserved.</p>
</footer>
</>
)
}WhimbrelOP
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 <footer> in <body>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
Component Stack
footer
Footer
body
html
Error: Hydration failed because the initial UI does not match what was rendered on the server.
Warning: Expected server HTML to contain a matching <footer> in <body>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
Component Stack
footer
Footer
body
html
This is the error I am getting
@Whimbrel This is the page.js
import {
PopoverDemo, MyBio,
Hobby,
Navbar, Footer,
} from './components/interload';
import RootLayout from './layout'
export default function Page() { return (
<RootLayout>
<Navbar />
<PopoverDemo />
<MyBio />
<Hobby />
</RootLayout>
)
}
You dont need to call rootlayout again here
Answer
Its already nested for you
WhimbrelOP
Hey thanks @alfon for helping out 
