“reagir nativo asyncstorage getItem” Respostas de código

AsyncStorage reagir nativo

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

Reacto o exemplo do SetItem Native AsyncStorage

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

  console.log('Done.')
}
Puzzled Puffin

reagir nativo asyncstorage getItem

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

Reacto o SetItEm Native AsyncStorage

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

Reacto o exemplo nativo asyncStorage getItem

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

  console.log('Done.')

}
Puzzled Puffin

Respostas semelhantes a “reagir nativo asyncstorage getItem”

Perguntas semelhantes a “reagir nativo asyncstorage getItem”

Mais respostas relacionadas para “reagir nativo asyncstorage getItem” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código