“Penyimpanan async bereaksi asli” Kode Jawaban

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 bereaksi asli

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

cara menginstal asyncstorage di react native

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

NPM React-native-Async-Storage

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

bereaksi penyimpanan asli

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

Penyimpanan async bereaksi asli


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

Jawaban yang mirip dengan “Penyimpanan async bereaksi asli”

Pertanyaan yang mirip dengan “Penyimpanan async bereaksi asli”

Lebih banyak jawaban terkait untuk “Penyimpanan async bereaksi asli” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya