Why new data isn't fetched when I refresh the page?
Answered
Satin Angora posted this in #help-forum
Satin AngoraOP
In a client page, after writing some data to database when I refresh the page to see the new data, page is rendered with stale data. As far as my Google-fu, this is expected; here is related information on my project;
- Data is fetched with Firestore SDK, and I have opted-out of caching in configs
- Related page is a client page
- Related components fetch data in
- Multiple reloads doesn't seem to work neither, (F5, Shift+F5, Ctrl+Shift+F5...)
The
Do you have any idea about how to approach this issue?
- Data is fetched with Firestore SDK, and I have opted-out of caching in configs
- Related page is a client page
- Related components fetch data in
useEffect calls- Multiple reloads doesn't seem to work neither, (F5, Shift+F5, Ctrl+Shift+F5...)
The
router.refresh is mentioned in a few places, but I'm not sure how to use it exactly; after a router.push? Before/after rendering the page? In a useEffect?Do you have any idea about how to approach this issue?
Answered by Satin Angora
I think issue is not on the data preparation algorithm, but rather there is an issue with my server code.
17 Replies
Satin AngoraOP
Yep.
useEffect(() => {
if (userMap === undefined) fetchAllUsers()
}, [fetchAllUsers, userMap]) Maybe this call is the culprit.so the data show correctly at first visit but not updating later?
Satin AngoraOP
I expect the newly written data to be fetched when I refresh the page.
@Satin Angora typescript
useEffect(() => {
if (userMap === undefined) fetchAllUsers()
}, [fetchAllUsers, userMap]) Maybe this call is the culprit.
yes could be this, but a refresh should fetch the data again?
Satin AngoraOP
I'm not really sure. As far as I see, logging in and out works, but it may be because there are route changes in between.
is your page on vercel that can share here?
Satin AngoraOP
No, working locally right now.
add a
console.log(userMap) and see if the data is updated after refresh?Satin AngoraOP
Let me see.
Satin AngoraOP
I think issue is not on the data preparation algorithm, but rather there is an issue with my server code.
Answer
Satin AngoraOP
I see the data is fetched, but in another part of the project, the related data doesn't appear
I should check my server code
oh ok at least you found it out
Satin AngoraOP
Yep 🙂 TY for your time.