The documentation says:
You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document s
What also worked for me was to check for the document.readystate and then choose to act on the snapshot changes. Like this -
db.collection("collectionName").onSnapshot( (snapshot) => {
console.log(snapshot.docChanges())
if( ["loaded","interactive", "complete"].indexOf(document.readyState) >=0 ){
<-----Your code to act on the snapshot changes---->
}
Based on the readystate property documentation here - https://www.w3schools.com/jsref/prop_doc_readystate.asp