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

feat: respect cancelRefetch flag for infinite queries (fetchNextPage, fetchPreviousPage) #2731

Conversation

lgenzelis
Copy link
Contributor

@lgenzelis lgenzelis commented Sep 27, 2021

closes #2617

Changes

  • Added cancelRefetch to FetchNextPageOptions and FetchPreviousPageOptions interfaces
  • Pass cancelRefetch flag down to this.fetch, defaulting it to true
  • Added .idea folder to .gitignore (Webstorm project config folder)

@vercel
Copy link

vercel bot commented Sep 27, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tannerlinsley/react-query/6CW2HtrMoySqhpNm8ByJWWDMGSmQ
✅ Preview: https://react-query-git-fork-lgenzelis-feat-respec-cf9eb3-tannerlinsley.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 27, 2021

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 4c1194d:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query: basic-typescript Configuration
react-query-infiniteQuery-bug Issue #2617

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome. could you please

@lgenzelis
Copy link
Contributor Author

lgenzelis commented Oct 4, 2021

@TkDodo I'm sorry, I feel a bit lost about the testing part. Could you please point me to an example where cancelRefetch is being tested? (for regular non-infinite queries, I mean)

@TkDodo
Copy link
Collaborator

TkDodo commented Oct 4, 2021

I would probably just test if cancel on the query itself has been called:

https://github.com/tannerlinsley/react-query/blob/e6da990703482cff8ea99f5a254975cb57463ed5/src/core/query.ts#L362-L364

@lgenzelis
Copy link
Contributor Author

@TkDodo I addressed your points 😃

  • updated documentation
  • added tests for the cases where cancelRefetch is omitted (so, it's true) and when cancelRefetch: false is passed to fetchNextPage

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@TkDodo
Copy link
Collaborator

TkDodo commented Oct 9, 2021

Would you consider this a feature rather than a bugfix ?

@TkDodo TkDodo merged commit 115895f into TanStack:master Oct 9, 2021
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 3.26.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lgenzelis
Copy link
Contributor Author

Would you consider this a feature rather than a bugfix ?

@TkDodo I guess so. Mainly because we didn't agree that the previous behavior was a bug on the first place 🤷‍♀️

@lgenzelis lgenzelis deleted the feat/respect-cancelRefetch-flag-for-fetchNextPage-and-fetchPreviousPage branch October 11, 2021 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useInfiniteQuery fetchNextPage function is inconsistent with refetch
3 participants