“AsyncStorage React Native” Ответ

AsyncStorage.getAllkeys

importData = async () => {
  try {
    const keys = await AsyncStorage.getAllKeys();
    const result = await AsyncStorage.multiGet(keys);

    return result.map(req => JSON.parse(req)).forEach(console.log);
  } catch (error) {
    console.error(error)
  }
}
Dark Dormouse

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
Bored Buzzard

Отрешите Native TypeScript

npx react-native init MyApp --template react-native-template-typescript
Friendly Finch

Как установить асинхноризм в RACET Native

npm i @react-native-community/async-storage
Wicked Wren

получить данные из AsyncStorage React Native

let user = await AsyncStorage. getItem('user');
let parsed = JSON. parse(user);
Dark Dormouse

отреагировать на собственное хранилище

npm install react-native-storage
npm install @react-native-community/async-storage
Wandering Wren

Ответы похожие на “AsyncStorage React Native”

Вопросы похожие на “AsyncStorage React Native”

Больше похожих ответов на “AsyncStorage React Native” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования