Closed
Description
Reproduction
https://stackblitz.com/edit/vitejs-vite-wlriny?file=src%2FApp.vue
Steps to reproduce the bug
The reproduction example show ways to use useDocument
and useCollection
const userDocumentComputed = useDocument(
computed(() => {
return currentUser.value ? doc(db, 'users', currentUser.value.uid) : null;
})
);
const userDocument = useDocument(() => {
return currentUser.value ? doc(db, 'users', currentUser.value.uid) : null;
});
const userFriends = useCollection(() => {
return currentUser.value
? collection(db, 'users', currentUser.value.uid, 'friends')
: null;
});
const userFriendsComputed = useCollection(
computed(() => {
return currentUser.value
? collection(db, 'users', currentUser.value.uid, 'friends')
: null;
})
);
- Login as a user
- Noticed how the data coming from a function won't change to the correct values, but data coming from computed will
- Logout and login as another user
Expected behavior
Acording to the documentation, you can pass both a getter or a computed().
https://vuefire.vuejs.org/guide/realtime-data.html#Declarative-realtime-data.
So userDocument
and userFriends
should update when you change user
Actual behavior
refs that were created by using an getter are not reactive (userDocument
and userFriends
)
Additional information
This looks like a bug as the documentation show the usage of a getter.
Either way, I'm willing to dive into the source code to understand/fix the bug, or to update the documentation to make it clear that getters aren't supported.