【问题标题】:TypeError: undefined is not an object (evaluating 'Uo.getRandomValues') Firebase/firestore react-nativeTypeError: undefined is not an object (evalating 'Uo.getRandomValues') Firebase/firestore react-native
【发布时间】:2020-07-21 15:58:39
【问题描述】:

我在尝试访问 Firestore 集合时不断收到此错误

这是我的 Firebase 配置

import Firebase from "firebase";
import "firebase/auth";
import "firebase/firestore";

let config = {
  apiKey: "xxx",
  authDomain: "xxx.firebaseapp.com",
  databaseURL: "https://xxx.firebaseio.com",
  projectId: "xxx",
  storageBucket: "xxx.appspot.com",
  messagingSenderId: "xxx",
};

let fb = Firebase.initializeApp(config);
let firestore = fb.firestore();

export const db = firestore;
export const auth = fb.auth();
export const firebase = fb;

组件中的导入和使用:

import { db } from "./src/plugins/firebase";

      db.collection("collection")
        .doc(docId)
        .collection("subcollection")
        .doc(subdocId).set({
        some object
      })

我在Type Error undefined is not an object (evaluating 'Wu.getRandomValues')中看到过类似的问题

所以我将 firebase 降级到 7.9.0 但它没有修复它...

这仅在使用选项--dev false 运行 react-native 捆绑包时才会发生,如果 --dev true 我没有收到错误...

【问题讨论】:

    标签: firebase react-native google-cloud-firestore


    【解决方案1】:

    我终于让它工作了...我已经尝试了所有删除 firebase 删除 package-lock.json 清除 npm 缓存并重新安装 firebase@7.8.2 但这些都不起作用...有效的是切换到 Yarn 而不是npm...所以我只是做了一个 yarn add firebase@7.8.2 并且它再次启动并运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-30
      • 2020-08-31
      • 2020-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      • 1970-01-01
      相关资源
      最近更新 更多