본문 바로가기
오류

[nextjs] You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default 오류 해결

by 개발고구마 2025. 2. 8.

x You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
| Learn more: https://nextjs.org/docs/getting-started/react-essentials
|
|
,-[C:\Users\vsc\app\main\artist[id]\page.tsx:1:1]
1 | import { useEffect, useState } from 'react';
:                                  ^^^^^^^^
2 | import { Button } from "@material-tailwind/react";
3 |

Import trace for requested module:
./app/main/artist/[id]/page.tsx

 

Build failed because of webpack errors


별건 아니고 page.tsx에 'use client'를 안붙여줘서 발생한 문제
클라이언트로 지정하지 않으면 react를 사용할 수 없다

해결

'use client' 추가