728x90
반응형
TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it.
원인
Next.js 13 app router 를 사용할 경우, React 관련 기능을 쓰려면 클라이언트로 컴포넌트로 작성해야 된다.
해결방안
Next.js에서는 컴포넌트가 클라이언트에서 작동하라고 지정하는 디렉티브를 쓴다.
파일 첫 줄에 'use clinet' 라고 입력하면, 그 파일은 자동으로 클라이언트 컴포넌트로 취급되고 컴파일된다.
728x90
반응형
'🌳Frontend > error log' 카테고리의 다른 글
[ERROR] command not found: nvm (2) | 2023.05.26 |
---|---|
[ERROR] Jest encountered an unexpected token.. (0) | 2023.05.24 |
[ERROR] Error: Invalid src prop .. is not configured under images in your (0) | 2023.05.18 |
jest 테스트코드 작성시 Cannot find module (2) | 2023.03.22 |
yarn install Fetching packages... 멈춤현상 (0) | 2023.03.22 |