Skip to content

useDocument().value is always undefined #1309

Closed Answered by posva
mateo-m asked this question in Questions and Help
Discussion options

You must be logged in to vote

The problem here is that composables are not being used correctly. I recommend you to give these a read:

In your code, if you only want to get the data once, you can use firebase directly with getDoc(). Otherwise the code you are writing should be within a script setup (like other reactivity api):

<script setup lang="ts">
  const db = useFirestore();
  const roomDoc = computed(() => doc(db, "rooms", roomId));

  const roomDocRef = useDocument<Room>(roomDoc);
  // or const { data: roomDocRef, pending, error } = ...
</script>

You have more examples in docs.

Note…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mateo-m
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1308 on February 14, 2023 17:18.