끄적이는 개발노트
Expo - AsyncStorage 본문
728x90
AysncStorage란?
암호화 되지 않은 비동기적인 데이터를 관리하는 Key-Value 저장 시스템
앱 전역에서 사용할 수 있으며, LocalStorage 대신 사용
AsyncStroage 특징은 다음과 같다.
- 비동기(async / await)
- 문자열만 저장가능
- 앱 전체에 적용
- 암호화 x
- 영구 저장
1. 설치
yarn add @react-native-async-storage/async-storage
2. 데이터 저장
const setItem = async () => {
await AsyncStorage.setItem(key, value);
}
3. 데이터 가져오기
const getItem = async () => {
await AsyncStorage.getItem(key)
}
4. 데이터 삭제
const removeItem = async () => {
await AsyncStorage.removeItem(key)
}
728x90
'React Native' 카테고리의 다른 글
React Native - 환경설정(1) / Android Studio 설치 (0) | 2023.07.13 |
---|---|
Expo - 스크린 포커스 시 이벤트 주기 (0) | 2023.06.22 |
Expo - Bottom Tabs Navigator (0) | 2023.06.13 |
Expo - Navigation (3) (0) | 2023.06.13 |
Expo - Navigation (2) (0) | 2023.06.08 |