“Async Storage React Native” Réponses codées

asyncstorage.getallkeys

importData = async () => {
  try {
    const keys = await AsyncStorage.getAllKeys();
    const result = await AsyncStorage.multiGet(keys);

    return result.map(req => JSON.parse(req)).forEach(console.log);
  } catch (error) {
    console.error(error)
  }
}
Dark Dormouse

Asyncstorage React Native

yarn add @react-native-async-storage/async-storage // install by yarn
npm i @react-native-async-storage/async-storage // install by npm

// import
import AsyncStorage from '@react-native-async-storage/async-storage';


await AsyncStorage.setItem('@storage_Key', "value") // for store item
await AsyncStorage.removeItem('@storage_Key', "value") // for remove item
Bored Buzzard

comment installer asyncstorage dans React natif

npm i @react-native-community/async-storage
Wicked Wren

NPM React-Native-Async-Storage

npm install @react-native-async-storage/async-storage
MAKSTYLE119

Réagir le stockage natif

npm install react-native-storage
npm install @react-native-community/async-storage
Wandering Wren

Async Storage React Native


import AsyncStorage from '@react-native-async-storage/async-storage';
// store item
export const storeData = async (key, value) => {		
  try {
    await AsyncStorage.setItem(key, value);
    return {
        success: true
    }
  } catch (error) {
    return {
        success: false,
        error
    }
  }
}
// get item
export const getData = async (key) => {
  try {
    const value = await AsyncStorage.getItem(key)
    return {
        success: true,
        value
    }
  } catch(error) {
    return {
        success: false,
        error
    }
  }
}


export default {
    getData,
    storeData
}
Hamza javed

Réponses similaires à “Async Storage React Native”

Questions similaires à “Async Storage React Native”

Plus de réponses similaires à “Async Storage React Native” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code