STUDY/Others

[React Native] AppLoading 컴포넌트 에러

sinawi95 2021. 7. 25. 14:30
728x90

처음 배우는 리액트 네이티브(한빛미디어, 김범준)를 따라가던 도중 Apploading 컴포넌트를 사용할 때 오류가 발생하는 것을 찾게 되었다.

Error: Element Type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

이런 오류인데 AppLoading을 사용할때 관련 컴포넌트를 못가져와서 생기는 문제이다 .

책에선 import { AppLoading } from 'expo' 이런 방식으로 해당 컴포넌트를 사용하는데 Expo SDK 40 부터 기본 컴포넌트에서 빠져서 오류가 생긴다. 

이를 해결하는 방법은 패키지를 설치해서 사용하면 된다.

패키지 설치:

expo install expo-app-loading

사용:

import AppLoading from 'expo-app-loading'

 


내 한시간....