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

react native asyncstorage getItem example

getMyObject = async () => {
  try {
    const jsonValue = await AsyncStorage.getItem('@key')
    return jsonValue != null ? JSON.parse(jsonValue) : null
  } catch(e) {
    // read error
  }

  console.log('Done.')

}
Comment

react native asyncstorage setItem example

setObjectValue = async (value) => {
  try {
    const jsonValue = JSON.stringify(value)
    await AsyncStorage.setItem('key', jsonValue)
  } catch(e) {
    // save error
  }

  console.log('Done.')
}
Comment

react native asyncstorage getItem example

getMyStringValue = async () => {
  try {
    return await AsyncStorage.getItem('@key')
  } catch(e) {
    // read error
  }

  console.log('Done.')

}
Comment

react native asyncstorage setItem example

setStringValue = async (value) => {
  try {
    await AsyncStorage.setItem('key', value)
  } catch(e) {
    // save error
  }

  console.log('Done.')
}
Comment

react native asyncstorage getItem

static getItem(key: string, [callback]: ?(error: ?Error, result: ?string) => void): Promise
Comment

react native asyncstorage setItem

static setItem(key: string, value: string, [callback]: ?(error: ?Error) => void): Promise
Comment

PREVIOUS NEXT
Code Example
Javascript :: what is auth guard in angular 
Javascript :: javascript list comprehension 
Javascript :: canvas js in react 
Javascript :: Check Whether Variable Is String Or Number In JavaScript 
Javascript :: copy an array 
Javascript :: + javascript 
Javascript :: return the sum of an array 
Javascript :: redwood js 
Javascript :: access object property dynamically javascript 
Javascript :: convert json data into html table 
Javascript :: javascript symbol 
Javascript :: nodejs cluster 
Javascript :: how to get last element in array java scipt 
Javascript :: pdf to image javascript 
Javascript :: javascript function destructuring 
Javascript :: classlist toggle 
Javascript :: js modulo 
Javascript :: map function javascript 
Javascript :: ex:js 
Javascript :: pass component as props react 
Javascript :: use of slot in vue 
Javascript :: get x y z position of mouse javascript 
Javascript :: how ot make a background color faor evaluationbutton in flutter 
Javascript :: move li to bottom of list jquery selected value 
Javascript :: get JSON information into html control with javascript 
Javascript :: firstdata payment.js Form Validity 
Javascript :: react-resizable-rotatable-draggable 
Javascript :: javascript select element have long word 
Javascript :: cypress 7 migration 
Javascript :: swal go back to queue on click 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =