You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importFirebasefrom'firebase';import{firestoreBind}from'vuefire';import{defineStore}from'pinia'defineStore({id: 'user',state: ()=>({user: {},}),getters: {userProfile(state){console.log(state.user);/** Logs: * * { * value: { * // user data * } * } * *//** Expected: * * { * // user data * } * */returnthis.state.user;},},actions: {init(userId){constuserDocRef=Firebase.firestore().collection('users').doc(userId)returnfirestoreBind(this.user,userDocRef);},},});
Steps to reproduce the behavior
Use firestoreBind() to bind a document to a store property.
The document is bound as expected
Expected behavior
The document should be bound directly to the property passed as a first parameter of the firestoreBind function
Actual behavior
A new value property is created under the property to which the document was bound.
Additional information
I'm not 100% sure if this is a bug. I thought that state is already a reactive object so there's no need to create nested reactive refs when binding Firestore documents, but I suppose that firestoreBind() is not able to recognize that this is already a reactive object so it creates a new ref under this.user. Am I right?
Or maybe I'm just not using it properly with Pinia?
The text was updated successfully, but these errors were encountered:
wujekbogdan
changed the title
firestoreBind creates a value propertyfirestoreBind creates a value property
Jun 30, 2021
Reproduction
Steps to reproduce the behavior
firestoreBind()
to bind a document to a store property.Expected behavior
The document should be bound directly to the property passed as a first parameter of the
firestoreBind
functionActual behavior
A new
value
property is created under the property to which the document was bound.Additional information
I'm not 100% sure if this is a bug. I thought that
state
is already a reactive object so there's no need to create nested reactive refs when binding Firestore documents, but I suppose thatfirestoreBind()
is not able to recognize thatthis
is already a reactive object so it creates a newref
underthis.user
. Am I right?Or maybe I'm just not using it properly with Pinia?
The text was updated successfully, but these errors were encountered: