Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

juniusfree
Copy link

@juniusfree juniusfree commented Dec 9, 2024

This PR fixes #3778

Problem:

  • The current implementation uses a 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:

  • We now use 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.

Copy link

codesandbox bot commented Dec 9, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

codesandbox-ci bot commented Dec 9, 2024

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 453ba91:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 453ba91
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/6756c60f41e1050008e78441
😎 Deploy Preview https://deploy-preview-4758--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@juniusfree juniusfree changed the title fix: useQuery hook does not refetch after resetApiState fix(rtk-query): useQuery hook does not refetch after resetApiState Dec 9, 2024
@juniusfree juniusfree changed the title fix(rtk-query): useQuery hook does not refetch after resetApiState fix(rtk-query): useQuery hook does not refetch after resetApiState Dec 9, 2024
@juniusfree juniusfree marked this pull request as ready for review December 9, 2024 09:03
@juniusfree juniusfree requested a review from riqts December 9, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RTK-Query]: useQuery hook does not refetch after resetApiState (2)
2 participants