Skip to content

FR: Async Storage has been extracted from react-native core #5953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Befkadu1 opened this issue Jan 30, 2022 · 7 comments
Closed

FR: Async Storage has been extracted from react-native core #5953

Befkadu1 opened this issue Jan 30, 2022 · 7 comments

Comments

@Befkadu1
Copy link

[REQUIRED] Describe your environment

  • Operating System version: "expo": "43.0.2" (React native)
  • Browser version: _____
  • Firebase SDK version: 9.6.5
  • Firebase Product: auth (auth, database, storage, etc)

[REQUIRED] Describe the problem

Steps to reproduce:

Relevant Code:

AsyncStorage will be removed from react-native core in the future release. It should be installed and imported from '@react-native-async-storage/async-storage' instead of 'react-native'. One of the issues is created here

See https://github.com/react-native-async-storage/async-storage for more information regarding AsyncStorage. Here the warning log is attached below.
Screenshot 2022-01-30 at 02 42 54

// TODO(you): code here to reproduce the problem
@sam-gc
Copy link
Contributor

sam-gc commented Jan 31, 2022

This should already be fixed in 9.6.5: https://firebase.google.com/support/release-notes/js#version_965_-_january_27_2022

How are you initializing the SDK?

@Befkadu1
Copy link
Author

Befkadu1 commented Jan 31, 2022

We can solve it by importing the latest AsyncStorage from @react-native-async-storage/async-storage

import AsyncStorage from "@react-native-async-storage/async-storage";
....
return AsyncStorage.getItem(...args); //line 63
...
 return AsyncStorage.setItem(...args); //line 67
 ....
 return AsyncStorage.removeItem(...args);  //line 71

@sam-gc
Copy link
Contributor

sam-gc commented Jan 31, 2022

@Befkadu1 please try manually initializing the SDK using this function:

initializeAuth(app, {
  persistence: getReactNativePersistence(/* your library */);
});

@hsubox76 hsubox76 added api: auth and removed bug labels Jan 31, 2022
@Befkadu1
Copy link
Author

@sam-gc it looks it works with this

const firebaseApp = initializeApp(config);
const Firebase =  initializeAuth(firebaseApp);

I have no idea with this one persistence: getReactNativePersistence(/* your library */); though. I would be glad if you have some kinda docs

@sam-gc
Copy link
Contributor

sam-gc commented Jan 31, 2022

Your snippet will not have persistence (it will just use in-memory). For example:

// This is from your snippet up above:
import AsyncStorage from "@react-native-async-storage/async-storage";

import {getReactNativePersistence, initializeAuth} from 'firebase/auth/react-native';

initializeAuth(app, {
  persistence: getReactNativePersistence(AsyncStorage);
});

See also: #1847

Unfortunately we don't have any documentation about this at the moment; it's a relatively recent fix/update.

@hsubox76
Copy link
Contributor

I'll look into making sure getReactNativeLocalPersistence() gets added to the docs.
While we don't have that specifically yet, here's the signature for initializeAuth() in general, which shows how to provide persistence object(s).
https://firebase.google.com/docs/reference/js/auth.md#initializeauth

@Befkadu1
Copy link
Author

@sam-gc Thanks a lot, it works awesome

@hsubox76 hsubox76 closed this as completed Feb 4, 2022
@firebase firebase locked and limited conversation to collaborators Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants