[Next.js] AWS Amplify 빌드 과정에서 Type error: 'Component' cannot be used as a JSX component. 에러 해결

이나원·2023년 10월 20일
0

트러블슈팅

목록 보기
6/7

에러 메시지

./src/pages/_app.tsx:17:8
Type error: 'Component' cannot be used as a JSX component.
Its element type 'Component<any, any, any> | ReactElement<any, any> | null' is not a valid JSX element.
Type 'Component<any, any, any>' is not assignable to type 'Element | ElementClass | null'.
Type 'Component<any, any, any>' is not assignable to type 'ElementClass'.
The types returned by 'render()' are incompatible between these types.
Type 'React.ReactNode' is not assignable to type 'import("/codebuild/output/src3096690837/src/prorataart-showroom-front/node_modules/@types/react-dom/node_modules/@types/react/ts5.0/index").ReactNode'.
Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.
  • 에러 해결 방법

다음과 같이 package.json에 resolutions를 작성해주면 된다.

"resolutions": {
  "@types/react": "18.0.31" // 본인의 react 버전
}
profile
프론트엔드 개발자로 재직 하면서 겪은 개발 과정을 기록하는 곳입니다 🙌

0개의 댓글