Warning: Prop `className` did not match. Server: Client:
This is probably one of the most annoying problem with Next.js, Typescript and styled-component luckily there's a work around for this.
You're gonna need to install babel-plugin-styled-components
yarn add --dev babel-plugin-styled-components
Create a file named .babelrc in the root directory and configure it. Here's the config file.
{
"presets": [
"next/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true,
"preprocess": false
}
]
]
}
Restart your server and refresh your server and you should be good.
Ciao
Top comments (6)
Is an alternate config file for the .babelrc file, I haven't tried it yet, I'll update this when I do.
Made an account just to say thank you! I've been stuck on this for days!
Recently got laid off. And have been feeling like crap, just gave me the push I needed. Thank you @kamcoder5
Thanks this fix my problem
Happy to help βΊοΈ
thanks