Home > Software engineering >  AsyncStorage are deprecated using React native
AsyncStorage are deprecated using React native

Time:11-26

I'm trying to use MQTT on freact native so I had to use AsyncStorage in my code when I try to import it from react native it was deprecated. any help please.

 import init from 'react-native-mqtt'
 import { AsyncStorage } from 'react-native'

init({
  size: 10000,
  storageBackend: AsyncStorage,
  defaultExpires: 1000 * 3600 * 24,
  enableCache: true,
  reconnect: true,
  sync : {
  }
});

CodePudding user response:

Yes AsyncStorage is deprecated and they advice to use one of its community packages for implementing async storage. Also there is another key-value pair storage type which is called mmkv, said to be faster than AsyncStorage.

Check this link out for Community Packages for AsyncStorage https://reactnative.directory/?search=storage

CodePudding user response:

AsyncStorage is now separated from React Native. Here is the new repo docs:

https://react-native-async-storage.github.io/async-storage/docs/install/

Usage:

import init from 'react-native-mqtt'
import AsyncStorage from '@react-native-async-storage/async-storage';

init({
  size: 10000,
  storageBackend: AsyncStorage,
  defaultExpires: 1000 * 3600 * 24,
  enableCache: true,
  reconnect: true,
  sync : {
  }
});
  • Related