Dipsundar Jana
Dipsundar Jana

Reputation: 34

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?

enter image description here

Upvotes: 0

Views: 547

Answers (1)

Cristian Poley
Cristian Poley

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

Related Questions