Reputation: 34
This code block is written in Firebase v8 syntax but how to write this code using firebase v9?
Upvotes: 0
Views: 547
Reputation: 246
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).
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 } }
)
Upvotes: 1