220405 스타일이 적용되기 전에 렌더가 되어버리는 문제
프로젝트 루트폴더에 아래와 같이 작성하여 추가하니 해결됨.
styled-components는 동적으로 className을 생성하는데 Next.js는 Pre Rendering을 지원하기 때문에 이후에 서버와 클라이언트의 className이 달라지면서 생기는 문제.
해당 플러그인은 서버와 클라이언트의 클래스명을 일치시켜줌.
npm i --save-dev babel-plugin-styled-components
// .babelrc
{
"presets": ["next/babel"],
"plugins": [
[
"babel-plugin-styled-components",
{ "fileName": true, "displayName": true, "pure": true }
]
]
}