Function useDocumentData

  • Returns and updates the data of a Firestore DocumentReference

    Type Parameters

    • AppModelType = DocumentData

      Shape of the data after it was converted from firestore

    • DbModelType extends DocumentData = DocumentData

      Shape of the data in firestore

    Parameters

    • reference: undefined | null | DocumentReference<AppModelType, DbModelType>

      Firestore DocumentReference that will be subscribed to

    • Optionaloptions: UseDocumentDataOptions<AppModelType>

      Options to configure the subscription initialValue: Value that is returned while the document is being fetched.

    Returns UseDocumentDataResult<AppModelType>

    Document data, loading state, and error

    • value: Document data; undefined if document does not exist, is currently being fetched, or an error occurred
    • loading: true while fetching the document; false if the document was fetched successfully or an error occurred
    • error: undefined if no error occurred