简体   繁体   English

如何使用 firebase v9 编写 firebase v8 代码

[英]how to write firebase v8 code using firebase v9

This code block is written in Firebase v8 syntax but how to write this code using firebase v9?此代码块是用 Firebase v8 语法编写的,但如何使用 firebase v9 编写此代码?

在此处输入图片说明

You need to check the Firebase documentation for the upgrade to V9, and you need update your library react-firebase-hooks to 4.0.0 version ( here documentation ).您需要查看Firebase 文档以升级到 V9,并且需要将库react-firebase-hooks更新到 4.0.0 版本( 此处文档)。

In your example, it would look like this:在您的示例中,它看起来像这样:

import { useCollection } from 'react-firebase-hooks/firestore'
import { getFirestore, collection, query, where } from 'firebase/firestore'

const db = getFirestore(firebaseApp);

const q = query(collection(db, 'chats'), where('users', 'array-contains', user.email));
const [value, loading, error] = useCollection(
  q,
  { snapshotListenOptions: { includeMetadataChanges: true } }
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM