0
votes

I'm trying my app on Android Device and when I start the app the dubbuger give me 1 Error and 1 Warning.

The Error is:

Async Storage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/async-storage' instead of 'react-native'. See https://github.com/react-native-community/react-native-async-storage

and the Warning:

Require cycle: node_modules/pouchdb-find/node_modules/pouchdb-utils/lib/index-browser.js -> node_modules/pouchdb-find/node_modules/pouchdb-utils/lib/index-browser.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

About the Error, I have follow what it said, I have done:

npm i --save @react-native-community/async-storage;

on my root project folder. And then

react-native link @react-native-community/async-storage

And At the last I have imported this: import AsyncStorage from '@react-native-community/async-storage'; on my project.

But I have always the same error. How can I solve in your opinion this error and this warning? Thank you!

3
Also make sure you're removing the old async storage using something like npm uninstall @react-native/async-storage - user7944473
If you are still getting the warning about AsyncStorage the chances are that you haven't updated all the imports where you are using AsyncStorage. Do a search of your app and make that you are no longer using import { AsyncStorage } from 'react-native' anywhere in your app. - Andrew

3 Answers

1
votes

The first step its correct and you're installing and linking the project dependencies into your project.

# Install
$ yarn add @react-native-community/async-storage

# Link
$ react-native link @react-native-community/async-storage

The second step seems correct too.

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

Note: Sometimes the error message comes from how you are storing the data

Can you write this part for me, I'll check the issue ?

For remove yellow warning you can:

To disable the yellow box place console.disableYellowBox = true;
anywhere in your application. Typically in the root file so it will apply to both iOS and Android.
console.ignoredYellowBox = ['Warning: Each', 'Warning: Failed'];

Can you try this ?

import {YellowBox} from 'react-native';
YellowBox.ignoreWarnings(['Warning: Each', 'Warning: Failed']);
1
votes

AsyncStorage used to be a part of the react-native library, but it is now deprecated. The module was removed from the standard library and is now a part of a separate library called @react-native-community/async-storage.

You did not mention if you are using Expo and you did not mention what version of React Native you are using, but in any case, this is the documentation for it: https://github.com/react-native-community/async-storage

If you are using RN 60+ you need to undo that link, as RN 60+ now uses autolinking. So you would run: react-native unlink @react-native-community/async-storage per the above documentation.

If you are using react-native-cli and not Expo, you probably also need to do a pod deintegrate and pod install to add

- "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)"

to your Podfile.lock file.

0
votes

first thing: these messages are warnings and they are safe to ignore in this case

console.disableYellowBox = true;

is your friend.

second: you probably are doing things correctly, but you are not the only one who uses AsyncStorages. Probably some packages inside node_modules are using AsyngStorage too, and they are your source of warning. The only solution to this to get updated packages and/or edit them yourself and remove incorrect imports.