Журналы ошибок:
Код: Выделить всё
You are initializing Firebase Auth for React Native without providing
AsyncStorage. Auth state will default to memory persistence and will not
persist between sessions. In order to persist auth state, install the package
"@react-native-async-storage/async-storage" and provide it to
initializeAuth:
import { initializeAuth, getReactNativePersistence } from 'firebase/auth';
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
const auth = initializeAuth(app, {
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
});
ERROR [runtime not ready]: Error: Component auth has not been registered yet, js engine: hermes
import { initializeApp, getApp } from "firebase/app";
import { getStorage } from "firebase/storage";
import { initializeFirestore } from "firebase/firestore";
import { initializeAuth, getAuth } from "firebase/auth";
import { Platform } from "react-native";
const firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: "",
};
console.log("
// Initialize Firebase App
console.log("
const app = initializeApp(firebaseConfig);
console.log("
// Initialize Auth with proper persistence for React Native
console.log("
let auth;
if (Platform.OS === "web") {
auth = getAuth(app);
} else {
try {
const ReactNativeAsyncStorage =
require("@react-native-async-storage/async-storage").default;
const { getReactNativePersistence } = require("firebase/auth");
auth = initializeAuth(app, {
persistence: getReactNativePersistence(ReactNativeAsyncStorage),
});
} catch (error) {
console.warn(
"
error
);
auth = getAuth(app);
}
}
export { auth };
// Use initializeFirestore to specify the region (asia-south1 for Mumbai)
console.log("
export const db = initializeFirestore(app, {
host: "asia-south1-firestore.googleapis.com",
ssl: true,
});
console.log("
console.log("
export const storage = getStorage(app);
console.log("
console.log(
"
);
// Export both the auth instance and getAuth function
export { app, getApp };
export default app;
< /code>
Что я попробовал:
установлен @React-cnync-storage /async-storage
Убедитесь, что Hermes правильно настроен
Использование initizeauth () для реагирования. Предупреждение?>
Подробнее здесь: https://stackoverflow.com/questions/796 ... rage-issue
Мобильная версия