首页 > 解决方案 > 在 React(不是本机反应)中:存储在 Firestore 中的 Date 对象的行为将发生变化,您的应用程序可能会中断

问题描述

我在反应应用程序中收到以下错误消息:

@firebase/firestore:Firestore (4.13.0):存储在 Firestore 中的 Date 对象的行为将发生变化,您的应用程序可能会中断。

有人在反应应用程序中看到这个并修复它吗?你能分享你的见解/代码吗?

我看到了对Angular 应用程序的相同问题的引用: https ://github.com/firebase/firebase-js-sdk/issues/726

对于反应原生应用程序(建议不要对这个问题做任何事情): https ://github.com/invertase/react-native-firebase/issues/1024

标签: reactjsfirebase

解决方案


firebase.initializeApp({
  apiKey: "***********************",
  authDomain: "***********************",
  databaseURL: "***********************",
  projectId: "***********************",
  storageBucket: "***********************",
  messagingSenderId: "***********************"
});

const settings = {timestampsInSnapshots: true};
firebase.firestore().settings(settings);

只需在配置 firebase/firestore 代码的代码中添加上述两个语句。


推荐阅读