#Hydration Error after adding ThemeProvider
22 messages · Page 1 of 1 (latest)
use ***suppressHydrationWarning ***, this may fix the issue
import { ThemeProvider } from "@/components/theme-provider"
export default function RootLayout({ children }: RootLayoutProps) {
return (
<>
<html lang="en" suppressHydrationWarning>
<head />
<body>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
</ThemeProvider>
</body>
</html>
</>
)
}
Can you please tell me where to insert this code? I'm following the tutorial strictly, do I need to insert it into provider.tsx?
I also wanted to ask if it's normal that unexpected errors occur, although everything is clear in the tutorial? I just can't even repeat it - errors constantly occur. How do you live with this?)
Share your theme-provider code
Here
Share the code where u have used <ThemeProvider></ThemeProvider>
Sure
in the html tag, add ***suppressHydrationWarning *** after lang attribute
like this <html lang="en" suppressHydrationWarning>
Thank you very much! The error is gone! Does this eliminate the root cause of the error?
Why does this happen, I try to repeat exactly after the Guru in the tutorial and I get errors
Yes this is the recommended way to remove the error
directly coming from next.js docs
This happens due to Server side rendering may be, exact reason I also don't know
Have to study about it mate
Ok, thank you Bro!
The first 30 minutes of the tutorial have been taking me two days already, but I think I made the main screen. I wonder if this is the longest way - to try to repeat it? Or is it better to try to find some training... Although this is also training...
You can follow the tutorial, but at the same time try to understand the code
Do refer the documentation of whatever technology is being used
Here is the link to the docs for current issue
Have a good day, keep learning
Thank you very much!!!
most welcome