멈멈-토이프로젝트(next.js)2

클라이언트 컴포넌트에서 서버 컴포넌트 넣기

순9 2024. 8. 12. 17:42
728x90

에러 발생

async/await is not yet supported in Client Components, only Server Components. 
This error is often caused by accidentally adding `'use client'` 
to a module that was originally written for the server.
 A component was suspended by an uncached promise. 
 Creating promises inside a Client Component or hook is not yet supported, 
 except via a Suspense-compatible library or framework.

 

코드 상황

부모 컴포넌트 : 클라이언트

자식 컴포넌트 : 서버(비동기)

 

이게 가능한가...공문에서 찾아봄

Unsupported Pattern: Importing Server Components into Client Components
The following pattern is not supported. You cannot import a Server Component into a Client Component:

서버 구성 요소를 클라이언트 구성 요소로 가져올 수 없습니다.

직접적으로 넣는건 안된다고 한다 코드 수정 해야겠다

 

props로 서버컴포넌트를 클라이언트 컴포넌트로 전달 하는건 가능!