Skip to content

FirebaseError with useDocumentData Hook with firebase@10.6.0 #315

Open
@tomatommy-bs

Description

@tomatommy-bs

Issue: FirebaseError with useDocumentData Hook in React-Firebase Integration

Environment

  • Firebase Version: 10.6.0
  • Next.js Version: 14.0.2
  • React Version: 18+
  • React DOM Version: 18+
  • React Firebase Hooks Version: 5.1.1

Description

I'm encountering an error when trying to fetch a document from Firestore using the useDocumentData hook from react-firebase-hooks/firestore. The goal is to retrieve data from a specific document in Firestore.

Code Snippet

Here's the code snippet where the error occurs:

import { doc, getFirestore } from "firebase/firestore";
import { useDocumentData } from "react-firebase-hooks/firestore";
import { app } from "~/.firebase/client";

const [data, loading, error] = useDocumentData(
	doc(getFirestore(app), "sample-path", "sample-id"),
);

Error Message

However, I receive the following error:

FirebaseError: Expected type 'Query', but it was: a custom DocumentReference object

Additional Context

I followed the documentation for react-firebase-hooks and made sure that the Firestore instance is initialized correctly. The path and ID provided are also correct and exist in the Firestore database.

I'm seeking assistance to understand the cause of this error and how to resolve it. Any insights or suggestions to fix this issue would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions