-
[Next.js] Its return type 'Promise<Element>' is not a valid JSX element. 에NextJS 2023. 4. 14. 23:43

'YouMayLike' cannot be used as a JSX component.
Its return type 'Promise<Element>' is not a valid JSX element.
Type 'Promise<Element>' is missing the following properties from type 'ReactElement<any, any>': type, props, keyts(2786)서버컴포넌트에서 async키워드를 사용하였을 때 나오는 에러 메시지
방법1
에러가 나는 코드위에 다음 키워드 추가:
{/* @ts-expect-error Server Component */}

방법2
export const YouMayLike = async () => { return ( <> //jsx코드 </> ) as unknown as JSX.Element;화살표 함수로 변경 후 as unknown as JSX.Element 추가
'NextJS' 카테고리의 다른 글
[nextjs] Cannot update a component(``) while rendering a different component(``) 에러 (0) 2023.06.06 [Nextjs] fromdata 데이터 가져오기 / cause: Error: Multipart: Boundary not found (0) 2023.05.17 NextJS 13버전 설치 (0) 2023.03.26