Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
Comment

npm react-native-async-storage

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

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
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: a go to id js 
Javascript :: chrome.storage.local delete 
Javascript :: quiz javascript example with array 
Javascript :: jquey datatables 
Javascript :: javascript window screen 
Javascript :: jquery datatable draw false 
Javascript :: how to target checkbox in jquery 
Javascript :: JavaScript super() keyword 
Javascript :: what are closures 
Javascript :: react render for loop 
Javascript :: manage nodejs versions on windows 
Javascript :: Sum of Digits / Digital Root 
Javascript :: simple node rest 
Javascript :: line break in js 
Javascript :: combine 2 "arrays with objects" and remove object duplicates javascript 
Javascript :: enforcefocus select2 modal 
Javascript :: md5 checksum javascript 
Javascript :: vue implode array 
Javascript :: rich text react renderer 
Javascript :: JavaScript then() method 
Javascript :: onclick multiple functions react 
Javascript :: difference between react and react native 
Javascript :: monaco editor events 
Javascript :: reactjs alert 
Javascript :: props navigation in class component 
Javascript :: javascript get clock time in auto counter up 
Javascript :: map javascript 
Javascript :: proper to mixed fraction in javascript 
Javascript :: javascript iterate through object attributes 
Javascript :: javascript array some 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =