인프런 커뮤니티 질문&답변
createfiberfromtypeandprops 에러
해결된 질문
작성
·
549
1
다음과 같은 에러가 납니다
```
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you m₩
ight have mixed up default and named imports. Check the render method of `IndexPage`.
```
index page 파일은 다음과 같습니다.
import React, { FunctionComponent } from 'react'
import Text from 'components/Text'
const IndexPage: FunctionComponent = function () {
return (
<div>
<Text text="Home" />
</div>
)
}
export default IndexPage
별다른 에러는 없어 보이는데 왜일까요?
develop 명령어 실행시에 이런 콘솔창에 에러는 아니지만 이런 경고가 뜹니다.
```
warn ./src/pages/info.tsx
Attempted import error: 'components/Text' does not contain a default export (imported as 'Text').
```
gatsby-config.js와
gatsby-node.js는 모두 강의에 나온 그대로 설정하였습니다.
퀴즈
TypeScript의 Generic과 Types를 React 컴포넌트 props에 함께 적용할 때 얻는 주된 이점은 무엇일까요?
컴포넌트 스타일링의 유연성 증가
런타임 에러 감소 (정적 타입 검사)
서버 응답 속도 향상
번들 파일 크기 감소
답변 1
0
안녕하세요, inust33님!
Text 컴포넌트에 아래와 같은 코드가 있는지 확인 부탁드려요!
export default Text
만약 해당 코드가 있음에도 오류가 발생한다면 댓글로 깃허브 레포지토리 링크 남겨주시면 확인 후 답변 남겨드리겠습니다!





