Reputation: 45
I'm experimenting building a Next13 app. The new layout is cool, but it is messing up the rendering. I don't entirely understand the ordering of rending objects within the layout:
Navbar.tsx
"use client";
import Link from "next/link";
export default () => {
return (
<span className="flex justify-between">
<h1 className="text-xl">Navigation Bar</h1>
<ul className="flex gap-4">
<li>
<Link href="/">Home</Link>
</li>
<li>
<Link href="/user/login">Login</Link>
</li>
<li>
<Link href="/user/signup">Sign Up</Link>
</li>
</ul>
</span>
);
};
layout.tsx
import "./globals.css";
import NavBar from "./NavBar";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html className="bg-slate-500 font-robslab" lang="en">
<head>
<title>Stylitique</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</head>
<header>
<NavBar />
</header>
<body>{children}</body>
</html>
);
}
page.tsx (HOME)
export default function Home() {
return (
<main>
<h1 className="text-green-500">HOME</h1>
<p>
{" "}
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempora
sapiente, expedita praesentium a eligendi dolorem maiores nihil
consectetur ipsum, repudiandae sed deserunt delectus, facere repellat
ipsam sit possimus voluptatibus error!
</p>
</main>
);
}
I tried:
Anyone find a solution yet?
Upvotes: 3
Views: 4795
Reputation: 504
just put the component inside <body>
notice: no need of
<header>
<head>
...
</head>
<body>
<NavBar />
{children}
</body>
Upvotes: 7