-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rtk-query): useQuery
hook does not refetch after resetApiState
#4758
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1eb26d1:
|
✅ Deploy Preview for redux-starter-kit-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
useQuery
hook does not refetch after resetApiState
2.4.0 works fine for me, however on 2.5.0 and 2.5.1 |
@markerikson Any chance we can get this merged? Is there more work that needs to be done? |
453ba91
to
07898dd
Compare
This PR fixes #3778
Problem:
lastRenderHadSubscription
ref to track if the last render had a subscription. However, this ref can become out of sync with the actual subscription state, causing failed refetches, which lead to missing data and eventually stuck loading states.Solution:
promiseRef.current
to check if there was a previous subscription, as it is sufficient to track the subscription state. This removes redundant logic and ensures correct behavior.