React Native Expo shows Async Storage warning - react-native

i'm using React Native expo, and it shows
[Warning: 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].
i read this link and I understood that it's due to the fact that some dependencies are using old AsyncStorage, not the new one from community.
But I hardly found that any solution for Expo users. Is there any solution for Expo? Or if I have to manual change dependencies using the old AsyncStorage, how can i do it? Since I'm new to React Native, not really sure what to do..

In Expo you should always link the libraries that Expo includes in the App. So like mentioned in the docs here https://docs.expo.dev/versions/latest/sdk/async-storage/
expo install #react-native-async-storage/async-storage
is the correct import. If you are working with an old Expo-SDK this might be different, otherwise you should adapt your imports.

Now expo has migrated to use as well the community version as you can see here.
But if you get this warning definitely you have some dependency or more that still use the react-native-core version, if so please refer to the first answer to How to resolve using AsyncStorage (deprecated) warning? Using the community (correct) library:
if this is the case the best is as suggested in that answer is to
Your best course of action is to fork the repo and fix all instances of AsyncStorage to use the correct version, or open an issue.

This error occurs because firebase imports AsyncStorage from react native core and not the new library #react-native-async-storage/async-storage. I think firebase hasn't updated the by default import yet so you have to do it yourself.The way I fixed it was ;
Install react-native-async-storage: npm i #react-native-async-storage/async-storage
Go into the firebase index.js file that imports AsyncStorage from react native core: It is located at : 'node_modules/#firebase/auth/dist/rn'.
Create a variable that imports AsycnStorage from 'node-modules/#react-native-async-storage/async-storage' :
var AsyncStorage = require('../../../../#react-native-async-storage/async-storage');
Replace all uses of AsyncStorage in this file from react native core with new variable, i.e. replace "ReactNative__namespace.AsyncStorage" with "AsycnStorage",

Related

React native sync-storage vs AsyncStorage

I'm still fresh with React Native. Stumbled upon some projects that uses sync-storage and AsyncStorage. Is there any difference between these 2 storage packages, base on scenario?
I've never heard of the sync-storage package but after looking into it, I can see that it relies on the deprecated package for async storage. Anyone who has been using async storage recently in react-native will point you towards the most up to date library: #react-native-async-storage/async-storage.

In Expo v35 managed workflow, how to handle `Warning: Async Storage has been extracted from react-native core`?

I use expo SDK v35, and works on the managed workflow (one without eject).
In my project, I face warning whenever I use AsyncStorage as demonstrated by their doc.
This, however, results in following warning being emitted:
Warning: 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
I tried to follow the instruction given by this warning, and tried to use #react-native-community/async-storage, but it did not succeed; it appears the library requires some linking, which is not available if you want to work inside the Expo's managed workflow.
Question
What is the proper way to handle AsyncStorage warning when working on expo's managed workflow?
Env
Expo 35.0.0
Recently I began developing a simple app using react native and the expo cli. However, on the react native docs, it seems that asyncStorage is getting deprecated. The solution would normally be to use the react community version but that is not compatible with expo.
https://github.com/react-native-community/async-storage/
There is currently no scope of linking libraries while using the managed workflow of expo. I've faced similiar issues , and was bound to migrate from expo to pure react native. And expo isnt meant for production as apps are slower. Better i would suggest you to migrate to pure React native . Async storage cant be used otherwise and if deprecated , you will be in a great problem in the future for your app.

How to manually link React Native new components with expo?

Right now I am trying to add sqlite-storage(https://github.com/andpor/react-native-sqlite-storage) and react-native-fs(https://github.com/itinance/react-native-fs/) to a project being done in react-native. Both, however, require me to add some lines of code to the ios and android files. Case is, I created this project using expo, and expo doesn't seem to have those files available.
Currently, I am trying to create some sort of offline storage for my app (I think I'll ditch sqlite because it won't be as necessary and just keep the react-native-fs and write the data on JSON).
I have already tried linking and re-installing it many times and it doesn't seem to work, since it keeps returning the "RNFSManager is undefined" error when I use react-native-fs. A few of the people with this problem I found said they had to manually link, but they all had access to those files I don't have (like setting and gradle, things expo doesn't give me direct access to), so I am not sure what I should do.
SQLite and FileSystem are both included on expo.
First you need to add them to your project with:
expo install expo-sqlite
expo install expo-file-system
Then you only need to import them
import { SQLite } from 'expo-sqlite';
import * as FileSystem from 'expo-file-system';
For more info you can check the expo docs for
FileSystem
and
SQLite
You will need to eject your expo project, so the android and ios folder will be created.
After that, you will be able to add nativecode to your react-native app.
The expo documentation is nicely done, you will have all the infos about the pros and cons of ejecting

Migrating AsyncStorage data when moving from React Native to Expo

I'm considering moving from React Native to Expo but to do this have to be able to read the old AsyncStorage data written using the React Native app in the new Expo version.
I was able to build the new Android app using our existing .keystore so it correctly replaces the old installed app but the AsyncStorage in the Expo app is empty. I guess it's because it uses different backend? The docs mention this
On Android, AsyncStorage will use either RocksDB or SQLite based on what is available.
Anyway to workaround this?

React Native - Error on importing third party library

I am trying to use a library react-native-tinder-swipe-cards - github
The issue is that it's giving the following error:
"Seems you're trying to access ReactNative.Component from the
'react-native' package. Perhaps you meant to access 'React.Component'
from the 'react' package instead?"
I am using the latest version of react native. Although the error tells me what exactly to do, it's not actually part of my application that is causing the error. It's their library that is causing the issue because removing this line:
import SwipeCards from 'react-native-swipe-cards';
Removes the error. Has anyone had a similar problem and can help me resolve this?
The NPM published version is not up to date with React Native and is using the "old" way to bring in Component (from 'react-native' instead of 'react'). Looking at the github repo the code has actually been updated but nothing has been published to NPM for that update. Your best bet is to either contact the author and get them to publish a update to NPM or use the repo version (npm i git+https//github.com/meteor-factory/react-native-tinder-swipe-cards --save)