I'm currently working on integrating Firebase with next.js, and I've encountered an error in the console that reads:
FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore
Below is a snippet of the custom hook causing the issue:
import { onAuthStateChanged, User } from '@firebase/auth'
import { doc, onSnapshot, Unsubscribe } from 'firebase/firestore'
// rest of the code
In addition, I have a firebase.ts file where I set up my Firebase app configuration.
import { FirebaseApp, getApps, initializeApp } from 'firebase/app'
import { getAuth } from 'firebase/auth'
// rest of the code
I suspect that the problem lies within the custom hook file, particularly with the onSnapshot
function. Could it be an issue with how I'm passing the docRef? Any insights would be greatly appreciated!
The console.log(firestore)
log reveals:
type: "firestore-lite"
_app: FirebaseAppImpl
// more details about firestore object