Skip to content

streamline cancelRefetch #2916

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

Closed
TkDodo opened this issue Nov 11, 2021 · 0 comments
Closed

streamline cancelRefetch #2916

TkDodo opened this issue Nov 11, 2021 · 0 comments
Labels
Milestone

Comments

@TkDodo
Copy link
Collaborator

TkDodo commented Nov 11, 2021

It is currently not clear when a previously ongoing fetch will be cancelled. Imperative methods that trigger refetches behave differently per default, like:

refetch returned from useQuery defaults cancelRefetch to false
invalidateQueries, refetchQueries and resetQueries default cancelRefetch to false
fetchNextPage and fetchPreviousPage returned from useInfiniteQuery default cancelRefetch to true
As discussed on Twitter, not cancelling a refetch when you explicitly call one of the above methods might lead to wrong data being displayed / getting out-of-sync with the backend. The safer approach would be to always cancel when the user explicitly requests a refetch with one of the above mentioned options.

Proposed solution

  • Set the cancelRefetch flag to true per default on all imperative actions that support it
  • Users can opt-out by setting it to false
@TkDodo TkDodo added the v4 label Nov 11, 2021
@TkDodo TkDodo added this to the v4 milestone Nov 11, 2021
@TkDodo TkDodo closed this as completed Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant