问题
I use the firebase cloud for DB. Here is the link from Github Repo. (It's Gmail Clone)
https://github.com/Pijano97/gmail-clone
You can check all files on Github, but most important are :
- EmailList.js
- EmailRow.js
- Sidebar.js
- sectionSlicer.js
- Store.js
If you need to see how the site looks like here it is. https://clone-3857a.web.app/
I do not know why it renders "emails" (all emails) instead of starred(when I am on the starred section and try to remove star). When I remove the star it should still render me emailStars. Try couple of times to change sections from Inbox>Starred remove star and also to add it from Inbox then again remove it, you will see a bug.
const readData = (sectionChange, setEmails) => {
db.collection(sectionChange) // uzimi emails kolekciju
.orderBy("timestamp", "desc") // rapsoredi ih po timestampu
.onSnapshot((
snapshot // uzmi snapshot trenutni
) =>
setEmails(
// stavi mail da bude ovo
snapshot.docs.map((doc) => ({
id: doc.id, // id = doc.id nDqpnWjBpy....
data: doc.data(), // ovo je zapravo message,subject,to itd..
}))
)
);
console.log("I read base:", sectionChange);
};
useEffect(() => {
readData(sectionChange, setEmails);
}, [sectionChange]);
来源:https://stackoverflow.com/questions/65739606/react-js-redux-i-dont-know-for-some-reson-when-i-remove-star-from-starred