React Native

React native Async Storage

Machine_웅 2020. 1. 21. 17:02
728x90
반응형

https://github.com/react-native-community/async-storage

 

저장

storeData = async () => {
  try {
    await AsyncStorage.setItem('@storage_Key', 'stored value')
  } catch (e) {
    // saving error
  }
}

 

불러오기

getData = async () => {
  try {
    const value = await AsyncStorage.getItem('@storage_Key')
    if(value !== null) {
      // value previously stored
    }
  } catch(e) {
    // error reading value
  }
}

 

 

 

지우기

removeValue = async () => {
  try {
    await AsyncStorage.removeItem('@MyApp_key')
  } catch(e) {
    // remove error
  }

  console.log('Done.')
}
728x90
반응형

'React Native' 카테고리의 다른 글

react-native 해더 중앙 정렬 및 버튼  (0) 2020.01.27
React Native 비동기 처리 async / await  (0) 2020.01.22
react native php-> myqli 연동  (0) 2020.01.21
React Native FlatList 추가  (0) 2020.01.17
React Native ToastAndroid  (0) 2020.01.17