Here is my query:
firestore()
.collection('users')
.doc(userId)
.onSnapshot(doc => setUser(doc.data()))
.once(() => {
// Do some things just once here!
});
The setUser
function runs every time the collection's data changes because I set up a snapshot listener, and it's working perfectly.
However, the once
part is causing an issue. I only want the content inside that function to be executed once (when the query is initially run and never again). Am I using the wrong method? Is there a built-in feature or another approach in Firestore to achieve this requirement?