-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow queryRefs to be disposed of synchronously #11738
Conversation
🦋 Changeset detectedLatest commit: 7c3aec9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Found an issue with |
Ok ready to go 🙂 |
@@ -447,6 +450,92 @@ it("auto resubscribes when mounting useReadQuery after naturally disposed by use | |||
await expect(Profiler).not.toRerender({ timeout: 50 }); | |||
}); | |||
|
|||
it("does not recreate queryRef and execute a network request when rerendering useBackgroundQuery after queryRef is disposed", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This experiment helped me find a potential bug with useBackgroundQuery
where rerendering useBackgroundQuery
after the query ref is disposed (either by auto timeout or unmounting useReadQuery) could cause the queryRef
to be recreated and execute another network request. Added a test here to check for that which was failing before this change 🙂
/release:pr |
/release:pr |
/release:pr |
A new release has been made for this PR. You can install it with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for looking into this! 🚀
@alessbell this one is for you 🙂.
This removes the
setTimeout
in the queryRef dispose function so that it can be disposed of synchronously. The strict mode compatibility is now handled inuseSuspenseQuery
itself using the work done in #11412 that allows a queryRef to "resume" after it has been disposed without creating additional network requests.