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 :: devtool google 
Javascript :: click tester 
Javascript :: constructor js 
Javascript :: plus in javascript 
Javascript :: queryselector change alternative 
Javascript :: react-select-search useSelect hook 
Javascript :: remove all search engines chrome 
Javascript :: what are escape characters in javascript 
Javascript :: angular js get selectedGroup for optGroup 
Javascript :: js get dropdown value 
Javascript :: inbox 
Javascript :: JavaScript querySelector - By class 
Javascript :: eval javascript 
Javascript :: Session Time Out 
Javascript :: Number of trailing zeros of N! 
Javascript :: node js serve pdf file 
Javascript :: .map method 
Javascript :: how to disable option after select using jquery 
Javascript :: how to sent react from data in mongodb 
Javascript :: validator.js 
Javascript :: what does return do in javascript 
Javascript :: combine csv files javascript 
Javascript :: jq not contains 
Javascript :: jsonwebtoken 
Javascript :: if array javascript 
Javascript :: why node_modules are not installed anymore 
Javascript :: node.js vm 
Javascript :: array indexof 
Javascript :: splice method js 
Javascript :: array of 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =