Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

yarn react-native-async-storage

yarn add @react-native-async-storage/async-storage
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 :: how to loop object javascript 
Javascript :: get document height js 
Javascript :: js first letter capital 
Javascript :: last index array javascript 
Javascript :: pass an array to javascript in asp net core list 
Javascript :: js replace characters in a string 
Javascript :: js copy text to clipboard 
Javascript :: javascript open new tab window 
Javascript :: javascript un hiden element 
Javascript :: nodemon package.json start 
Javascript :: sum of number using reduce 
Javascript :: last item in object javascript 
Javascript :: jquery find id with string at end 
Javascript :: create number pyramid in javascript 
Javascript :: spacebar event listener 
Javascript :: javascript change frame background 
Javascript :: moment js year only 
Javascript :: regular expression to find a string between two characters 
Javascript :: how to get a channelid discord.js 
Javascript :: inline style in nextjs 
Javascript :: fs.unlink 
Javascript :: jquery change text color 
Javascript :: javascript add button to div 
Javascript :: js close window 
Javascript :: regular expression match text between quotes 
Javascript :: import { Application } from "express" 
Javascript :: vue add script tags and link tags 
Javascript :: dayjs timezone 
Javascript :: replace backward slash in javascript 
Javascript :: detect system dark mode javascrip 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =