React.js + REDUX… I don't know, for some reson when I remove star from starred section, it render me “emails”(all inbox) not “starredEmails”

為{幸葍}努か 提交于 2021-01-29 05:23:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!