[Next.js] Component selectors can only be used in conjunction with @emotion/babel-plugin 해결

2023. 2. 23. 18:46·Trouble Shooting
반응형

Next.js에서 emotion을 사용하고 있었는데, 컴포넌트 선택자를 사용하려는 중에 이런 오류를 만났다.

Server Error
Error: Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.

이게 뭐야!

 

컴포넌트 선택자는 상위 컴포넌트에서 하위의 컴포넌트를 선택해서 스타일링 하는 것을 의미한다.

import styled from '@emotion/styled'

const Child = styled.div`
  font-size: 14px;
`

const Parent - styled.div`
  ${Child} {
    background-color: yellow;
  }
`

 

next.config.js의 compiler 속성에 emotion: true를 설정해주면 해결 가능하다.

/** @type {import('next').NextConfig} */
const nextConfig = {
  // ...
  compiler: {
    emotion: true,
  },
}

module.exports = nextConfig

 

 

 

https://cheolsker.tistory.com/39

 

 

 

반응형

'Trouble Shooting' 카테고리의 다른 글

Delete `␍`eslint(prettier/prettier) 해결하기  (0) 2023.05.18
[passport] req#logout requires a callback function 오류 해결  (0) 2023.02.28
[Github Actions] the process '/usr/bin/git' failed with exit code 128 해결  (0) 2023.02.21
[Nginx] 페이지 새로고침 시 Page Not Found 오류 해결  (1) 2023.02.07
[Netlify] 페이지 새로고침 시 Page Not Found 오류 해결  (0) 2023.02.06
'Trouble Shooting' 카테고리의 다른 글
  • Delete `␍`eslint(prettier/prettier) 해결하기
  • [passport] req#logout requires a callback function 오류 해결
  • [Github Actions] the process '/usr/bin/git' failed with exit code 128 해결
  • [Nginx] 페이지 새로고침 시 Page Not Found 오류 해결
SH_Roh
SH_Roh
  • SH_Roh
    혼자공부끄적끄적
    SH_Roh
  • 전체
    오늘
    어제
    • 분류 전체보기 (159)
      • FE (39)
        • HTML, CSS (3)
        • Javascript (17)
        • React (11)
        • Next.js (4)
      • Network (1)
      • DevOps (4)
      • Git (1)
      • Trouble Shooting (24)
      • Algorithm (41)
        • Python (2)
        • Data Structure, Algorithm (7)
        • Problem Solving (31)
      • Education (23)
        • Elice AI Track (4)
        • Wanted Pre-Onboarding FE Co.. (19)
      • TIL (25)
      • Etc. (1)
        • 회고 (1)
        • 그냥저냥 (0)
  • 링크

    • Github
  • 인기 글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
SH_Roh
[Next.js] Component selectors can only be used in conjunction with @emotion/babel-plugin 해결
상단으로

티스토리툴바