Develop/React
[Develop/React] object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. 이슈
code_block
2020. 2. 20. 15:17
React 이슈 정리
어처구니없는 실수로 인하여 시간을 소비한 경험으로 인하여 블로그 포스팅을 작성한다.
Route를 이용하여 각 page를 설정하고 실행했는데 아래와 같은 에러 문구가 표출되었다.
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
위 내용을 조금만 자세히 읽었더라면 쉽게 해결할 수 있는 문제였는데 혹시나 다른 개발자들도 같은 이슈가
발생하여 시간을 허비 하지 않길 바란다.
결국 문제는 router component로 설정해놓은 page 컴포넌트가 비어 있었고 export 하는 부분이 없었기에 발생하였다.
또 다른 이슈로 import한 컴포넌트의 네이밍 문제로 발생하였다는 블로그도 보았다.
위와 같은 에러가 발생한다면 import 한 컴포넌트들이 제대로 export 되고 있는지 확인해야 한다.