Next.js Discord

Discord Forum

suppressHydrationWarning not work at all

Answered
Atlantic mackerel posted this in #help-forum
Open in Discord
Atlantic mackerelOP
Hey guys, Im trying to add dark mode use ThemeProvider
but when I after added this, the error said

app-index.js:35 Warning: Extra attributes from the server: class,style

So I search it, and I found suppressHydrationWarning option on body so I did it

export default function RootLayout({
                                       children,
                                   }: Readonly<{
    children: React.ReactNode;
}>) {
    const CookieProviderOverride = UserCookieProvider as any;

    return (
        <html lang="en">
        <body className={inter.className} suppressHydrationWarning={true}>
        <CookieProviderOverride>
            {children}
        </CookieProviderOverride>
        </body>
        </html>
    );
}

But the error said same thing as before.
How can I fix it?
Answered by joulev
next-themes? add the prop to <html> not <body>
View full answer

2 Replies