Open ducyb782001 opened 2 weeks ago
And now, isLoadingUserLevel always return true
https://stackblitz.com/edit/stackblitz-starters-xmhdkt?file=app%2Fpage.tsx
Step 1: Click go to photo Detail Step 2: Reload page Photo detail and don't wait api loading success Step 3: Spam click button go to list photo in page PhotoDetail (Dont wait api loading success) Step 4: When go to List photo, spam again on button go to photo detail
I expected isLoading work after reload and go to other page fast
Always when using this step
https://github.com/user-attachments/assets/33bc371b-052c-4136-af00-5bec36063a03
react-query
^4.35.3
^5
No response
Thank you for filing this issue, but we need more information before looking into this.
Specifically, a minimal, standalone, runnable reproduction is needed - preferably with codesandbox or stackblitz.
We'll close this issue for now, but we'll certainly re-open it if there is a proper reproduction.
@TkDodo thanks for your reply, i will give you a code sanbox soon. And you can see my video for more infor. Thanks
Hi @TkDodo , Sorry for the slowly response, i already update the stackbliz code example and step to have the bug. Here is my stackbliz link
https://stackblitz.com/edit/stackblitz-starters-xmhdkt?file=app%2Fpage.tsx
It’s an interesting race condition. Here’s a fork with v5 + the devtools where it still shows up:
https://stackblitz.com/edit/stackblitz-starters-fuohuu
It goes away when the list query is not used on the details page. I’ll have to look into why that happens.
Would be good to know if this is specific to nextJs or if it could be reproduced in other frameworks as well
I happened in the "Link" component of nextjs. If I moved the page before useQuery was done, the same thing happened to me.
https://stackblitz.com/edit/stackblitz-starters-4tjsxt?file=app%2Fpage.tsx
It didn't happen because the page was reloaded when using the 'a' tag.
@parkinjong so, to be on the same page: the issue doesn’t show up when router.push
is used, but it does show up when a next Link
is used ?
@TkDodo
When I tested it on stackblitz, router.push
and Link
look the same
Describe the bug
I have page 1 /photos and two useQuery function
const { data: profileDetail } = useQuery({ queryKey: ["userProfile"], queryFn: () => getProfileDetail(), }); const { data: listUserToken, isLoading: isLoadingUserToken } = useQuery({ queryKey: ["listUserToken"], queryFn: async () => { const result = await getListUserToken(); return result; }, });
I hard reload this page and don't wait the query is success => and click to push in page 2` <div onClick={() => { router.push("/photos/1"); }}
In page 2 i will have some other useQuery function
const { data: userExp } = useQuery({ queryKey: ["userExp"], queryFn: () => getUserExp(), }); const { data: profileDetail } = useQuery({ queryKey: ["userProfile"], queryFn: () => getProfileDetail(), }); const { data: userLevel, isLoading: isLoadingUserLevel } = useQuery({ queryKey: ["getUserLevel"], queryFn: () => getUserLevel(), });
And then i don't wait the query success, i click to push page into page 1 (/photos) ` <div onClick={() => { router.push("/photos"); }}