Is it possible to access the current selected layout segment from a component placed inside a root layout?
i.e.
export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html>
<head />
<body>
<NavMenu session={session} />
<GlobalHero /> {/* <- This is where I want to access the current route */}
{children}
</body>
</html>
);
}
// importing this causes a runtime error
// Error: Cannot read properties of null (reading 'useContext')
import { useSelectedLayoutSegment } from "next/navigation"
export default function GlobalHero() {
return ( <div> .... </div>)
}