Skip to content

useDocument().value is always undefined #1308

@mateo-m

Description

@mateo-m

Reproduction

Logging the reference and then logging the reference's value shows the issue.

Steps to reproduce the bug

  1. Using Firestore, create a collection called rooms.
  2. Create a room document inside the rooms collection with any kind of data, don't leave the room document empty.
  3. Pass the room's ID to the following function :
export const getRoomDocRef = (roomId: Room["id"]) => {
  const db = useFirestore();
  const roomDoc = computed(() => doc(db, "rooms", roomId));

  const roomDocRef = useDocument<Room>(roomDoc);

  console.log("Room", roomDocRef);
  console.log("Room value", roomDocRef.value);

  return roomDocRef;
};

Expected behavior

roomDocRef.value shouldn't be undefined.

Actual behavior

Here's the result in my browser's console :
Issue with useDocument()

I don't understand how _value (seen in the first log) can hold the correct values, while the second log (roomDocRef.value) returns undefined.

Additional information

I'm new to Vue, so I might be missing something there...

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