I have a layout like this:
export default async function ClientLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<>
<Header />
<main>{children}</main>
<Footer />
</>
);
}
And in Header I call fetchDepartments (and especially throw an error for now to check if error.tsx will be shown):
export default async function Header() {
const departments = await fetchDepartments();
return (
<header className={styles.navbar}>
<nav className={`${styles.container} container`}>
<Link href={"/"} className={styles.logo}>
<Image src={logo} priority={true} alt="logo" />
</Link>
{/*<DepartmentsSelectContainer />*/}
<Links />
<div className={styles.bookingBtn}>
<Link className={`btn yellow sm`} href={"/contacts"}>
Запис на прийом
</Link>
</div>
</nav>
</header>
);
}
But this error triggers Next.js default error modal except error.tsx.
There is a way to make layout 1 level above my current layout and put error.tsx in its layout folder, but in this situation, my header and footer won't be rendered -- but I need them rendered.