-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededneeds-infosuspense
Description
Describe the bug
When a user does client-side navigation to return to a previously visited page (react-router-dom), the useQuery hook is not invoked again, even if the query has been marked as invalid. This is an issue because the server value could change in a different browser session or device and the useQuery data value would no longer be in sync.
To Reproduce
Created a reproducible environment for testing the bug here:
https://codesandbox.io/s/ping-pong-react-query-client-guqhn
Important files: src/index.js and src/components/Demo.js
Steps to reproduce the behavior:
- Visit Page 1, note the number of pings, and click the increment button.
- In the mutation's onSuccess handler, we invalidate the queryCache and navigate to Page 2.
- Open a new tab and simulate the ping mutation by simply hitting this URL a few times:
-- https://1675g.sse.codesandbox.io/ping-increase - Navigate back to Page 1 via Link or browser back button and note that the value is only incremented by 1.
- If you refresh Page 1, you'll notice that the value now reflects the actual server value.
Expected behavior
On return to Page 1 from Page 2, I would expect the useQuery hook to fetch the latest server value.
Ebuall, jobn, johncantrell97, flybayer and vimcaw
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededneeds-infosuspense