I am getting this error when trying to use getReactNativePersistence in Expo with React Native.
"expo": "^49.0.0" and
"firebase": "^10.3.0"
This is my code:
import AsyncStorage from "@react-native-async-storage/async-storage";
import { initializeApp } from "firebase/app";
import { initializeAuth, getReactNativePersistence } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getStorage } from "firebase/storage";
// Your web app's Firebase configuration
const firebaseConfig = {...};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = initializeAuth(app, {
persistence: getReactNativePersistence(AsyncStorage),
});
const db = getFirestore(app);
const storage = getStorage(app);
export { auth, db, storage };
Error:
TypeError: (0 , _auth.getReactNativePersistence) is not a function
I have tried both cases and it looks like getReactNativePersistence doesn't exist at all:
import { initializeAuth, getReactNativePersistence } from "firebase/auth";
import { getReactNativePersistence } from 'firebase/auth/react-native';
Updating in case someone is using the latest version in 2024. I found a workaround for this on this comment in this issue here:
//@ts-ignore import { getReactNativePersistence } from '@firebase/auth/dist/rn/index.js';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With