1. 데이터 저장하기
const storeData = async task => {
try {
await AsyncStorage.setItem('tasks', JSON.stringify(task));
setTasks(task);
} catch (e) {}
};
const getData = async () => {
try {
const loadedData = await AsyncStorage.getItem('tasks');
setTasks(JSON.parse(loadedData || {}));
} catch (e) {}
};
- 이전에 Task 수정, 추가, 삭제시 작성했던 코드 수정
storeData({ ...tasks, ...newTaskObject });
const [isReady, setIsReady] = useState(false);
return isReady ? (
) : (
<AppLoading
startAsync={getData}
onFinish={() => {
setIsReady(true);
}}
onError={() => {}}
/>
);
2. 로딩화면과 아이콘
{
"expo": {
"name": "my-first-expo",
"slug": "my-first-expo",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}