[FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).]

[FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).]

在 react-native 中显示此错误请提供解决方案 Firebase:名为“[DEFAULT]”的 Firebase 应用已存在 (app/duplicate-app)。从“firebase”导入 * 作为 firebase; require("firebase/firestore") const firebaseConfig = { configuration }; // 初始化 Firebase firebase.initializeApp(firebaseConfig);变量数据库 = ...

你是不是用错包了?

安装

# Install & setup the app module
yarn add @react-native-firebase/app

# Install the firestore module
yarn add @react-native-firebase/firestore

用法

import firestore from '@react-native-firebase/firestore';

const usersCollection = firestore().collection('Users');

https://rnfirebase.io/firestore/usage