반응형
앱이든 웹이든 어떤 프로그램을 만들다 보면 화면이 로딩이 다 되기전에 미리 해야할 일들이 있다.
API를 통해 코드를 받아온다던가, 앱 로딩시 이미지를 보여준다던가.. DB를 생성하고 초기화를 한다던가..
이런 일련의 작업들을 하기위한 Expo API가 AppLoading 이다.
자세한 설명 링크는
https://docs.expo.dev/versions/latest/sdk/app-loading/
AppLoading - Expo Documentation
Expo is an open-source platform for making universal native apps for Android, iOS, and the web with JavaScript and React.
docs.expo.dev
설치는
npx expo install expo-app-loading
사용 소스 예저를 보면
import AppLoading from 'expo-app-loading';
export default function App(){
const [ready, setReady] = useState(false);
const onFinish = () => setReady(true); // 로딩이 끝날때 실행되는 콜백 함수
const isLoading = async() => {
// 여기에 초기에 실행될 작업들을 넣어 주면 된다..
}
if (!ready){
return <AppLoading
startAsync={isLoading}
onFinish={onFinish}
onError={console.error} />
}
return null;
}
생각보다 어렵진 않다.. ^^;; 아직까지는.. ㅎㅎ

정리를 해 나가면서 슬슬 구조를 익혀야겠다.
반응형
'모바일 앱 개발 > react-native' 카테고리의 다른 글
React-native Navigation (0) | 2022.10.06 |
---|---|
Asset (1) | 2022.10.05 |
Font(expo-font) (0) | 2022.10.05 |
React-native 시작하기.. (0) | 2022.10.04 |
댓글