I am making a react native app utilizing expo and typescript and attempting to create a enroll with firebase. I’ve one warn and two errors, please give me any concepts how you can repair that.
WARN [2023-09-07T14:57:25.221Z] @firebase/auth: Auth (10.3.1):
You’re initializing Firebase Auth for React Native with out offering
AsyncStorage. Auth state will default to reminiscence persistence and won’t
persist between classes. With a view to persist auth state, set up the bundle
“@react-native-async-storage/async-storage” and supply it to
initializeAuth:
ERROR [2023-09-07T14:57:25.254Z] @firebase/auth: Auth (10.3.1): INTERNAL ASSERTION FAILED: Anticipated a category definition
ERROR Error setting persistence: [Error: INTERNAL ASSERTION FAILED: Expected a class definition]
my firebase.tsx code:
import { Platform } from "react-native";
import firebase from "firebase/app";
import "firebase/compat/auth";
export const firebaseConfigAndroid = {
apiKey: "xxx",
authDomain: "xxx",
projectId: "xxx",
storageBucket: "xxx",
messagingSenderId:
"xxx",
appId: "xxx",
};
export const firebaseConfigIOS = {
apiKey: "xxx",
authDomain:
"xxx",
projectId: "xxx",
storageBucket: "xxx",
messagingSenderId: "xxx",
appId: "xxx",
};
let firebaseInitialized = false;
export const firebaseInitialize = () => {
if (!firebaseInitialized) {
const platform = Platform.OS;
const firebaseConfig =
platform == "android" ? firebaseConfigAndroid : firebaseConfigIOS;
firebase.initializeApp(firebaseConfig);
firebaseInitialized = true;
}
};
My code in SignUp:
const [firebaseInitialized, setFirebaseInitialized] = useState(false);
const [signupError, setSignupError] = useState<string | null>(null);
const platform = Platform.OS;
useEffect(() => {
if (!firebaseInitialized) {
const firebaseConfig =
platform === "android" ? firebaseConfigAndroid : firebaseConfigIOS;
const firebaseApp = initializeApp(firebaseConfig);
// Get the Firebase auth object
const auth: Auth = getAuth(firebaseApp);
// Arrange persistence with browser session persistence
setPersistence(auth, browserSessionPersistence)
.then(() => {
setFirebaseInitialized(true);
console.log("Firebase persistence arrange efficiently");
})
.catch((error) => {
console.error("Error setting persistence:", error);
});
}
}, [firebaseInitialized, platform]);