I am fetching a list of items from firestore in react native.
If an item document is updated, my list refreshes as expected through onSnapshot. But if the document is deleted, my list does not refresh.
Is there a way for me to catch deleted documents?
this.unsubscribe = firebase.firestore().collection('bigItems').doc(id)
.collection('littleItems').onSnapshot(this.getItems)
getItems = (querySnapshot) => {
const items = [];
querySnapshot.forEach((doc) => {
firebase.firestore().collection('events').doc(doc.id).get()
.then(item => {
const { id } = item.data();
items.push({
id: item.id
});
this.setState({
items: items,
loading: false,
});
})
.catch(function (err) {
return err;
});
})
}