Skip to content

[Issue] 페이지에서 material ui TextField 컴포넌트 사용시 스타일 깨짐 #21

Closed

Description

@devmhl

문제

  • page 폴더 아래 스크립트 파일에서 material ui <TextField /> 컴포넌트 사용시 스타일이 깨져버리는 에러 발생
  • TextField의 variant 속성값='outlined'만 저렇게 됨. 'filled' 등은 잘 반영됨.
    image

해결과정

  1. 콘솔에러 확인
Warning: Prop `className` did not match. Server: "PrivateNotchedOutline-legend-280" Client: "PrivateNotchedOutline-legend-5"
    at legend
    at fieldset
    at NotchedOutline

image

  1. 구글링
  1. babel-plugin-styled-components 설치
  • npm i babel-plugin-styled-components
  • .babelrc 설정
{
  "presets": ["next/babel"],
  "plugins": ["babel-plugin-styled-components"]
}

=> 해결안됨

Activity

  1. added a commit that references this issue on May 30, 2021
  2. devmhl commented on May 30, 2021

    @devmhl
    CollaboratorAuthor

    해결!

    • ssr 넥스트 레퍼런스 보고 theme.js, _document.js, _app.js 수정하여 해결함
    • 위키 기록 예정

    참고자료

    1. material UI 문서의 SSR 가이드
    2. 스택오버플로우 (React + Material-UI - Warning: Prop className did not match)
    3. Next 프로젝트에서 material UI SSR 적용한 소스코드
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions