When deleting a bank from the database, I need to redraw the screen and delete the card with the bank that I deleted. I wrote a filter function that returns elements that are not equal to the id of the element that was removed, but it does not work. How can it be solved?
function getBanks() {
db.collection("banks").onSnapshot((snapshot) => {
let banks = [];
snapshot.docChanges().forEach((change) => {
const bank = {
id: change.doc.id,
...change.doc.data(),
};
if (change.type === "added") {
banks.push(bank);
generateBanks([bank]);
} else if (change.type === "removed") {
banks.filter((item) => item.id != bank.id);
generateBanks([bank]);
}
});
});
}