일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- mockoon
- thread
- 리액트네이티브
- Basic
- 아키텍처
- link
- 쓰레드
- async
- sprinkles
- JavaScript
- 리액트
- react server component
- 기초
- 기본
- react-native
- Babel
- next.js
- react-query
- Cache
- Concurrent Mode
- 최적화
- React
- 동기
- 개발자
- 목킹
- vanilla-extract
- 비동기
- next hydration
- mock service worker
- 캐쉬
- styled-component
- 자바스크립트
- 컴포넌트
- SWC
- MSW
- front-end mocking
- Critical Rendering Path
- 리액트쿼리
- amplify
- CSS-in-JS
Archives
- Today
- Total
Don’t worry about failures
props 'className' did not match 본문
728x90
next.js는 초기 렌더링만 서버가 담당 ( SSR ) 이후 CSR로 동작을 한다.
첫 화면 로딩시에는 SSR로 렌더링하면서 오류가 발생하지 않지만, CSR로 렌더링하면서, 서버에서 클래스명과 클라이언트에서 클래스명이 달려져서 생기는 오류이다.
같은 Header를 home 쪽에서 ssr로 렌더링하고 다른 페이지 이동후 새로고침하면 기존에 있는 header( ssr로 내려온 header ) 와 페이지 이동된 후 header (csr로 그려준 header )의 클래스 해쉬 값이 달라 위와 같은 에러
해결방법
babel-plugin 설치
npm i babel-plugin-styled-components
프로젝트 루트 경로에 .babelrc 파일 생성 이미 존재하면 해당 값 기입
{
"presets": ["next/babel"],
"plugins": ["babel-plugin-styled-component"]
}
option
babel-plugin-styled-components에 옵션 주기
{
"presets": ["next/babel"],
"plugins": [
[
"babel-plugin-styled-components",
{
ssr: true,
displayName: true,
preprocess: false
}
]
]
}
728x90
'React' 카테고리의 다른 글
react query에 대해 (0) | 2022.02.27 |
---|---|
React Query 적용 (0) | 2022.02.21 |
Link vs router.push vs a (0) | 2021.09.26 |
React DOCS Reading study(5) (0) | 2021.06.23 |
React DOCS Reading study(4) (0) | 2021.06.22 |