Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonner causes hydration error in React because "In HTML, <section> cannot be a child of <html>" #528

Open
skoshx opened this issue Dec 18, 2024 · 0 comments

Comments

@skoshx
Copy link
Contributor

skoshx commented Dec 18, 2024

Basically, I'm trying to add Sonner to my Layout in Next.js:

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body
        className={`${inter.className} ${geistSans.variable} ${geistMono.variable} antialiased dark`}
      >
        {children}
      </body>
      <Toaster />
    </html>
  );
}

Which immediately gives hydration errors. So I guess React doesn't like <section> being a child of <html> which, in almost all cases it will be (man I hate React enforcing semantic correctness of HTML, so dumb imo). So I guess the root element for the Toaster should be changed to something like a div.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant