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(useQuery): make refetchInterval accept a function #2622

Merged
merged 10 commits into from
Oct 2, 2021

Conversation

TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Aug 31, 2021

so that we can have intervals dependent on current data / error

so that we can have intervals dependent on current data / error
@vercel
Copy link

vercel bot commented Aug 31, 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/CpE3rkSfacdTniSc2taTcuhiexU9
✅ Preview: https://react-query-git-fork-tkdodo-feature-refetc-3d6a19-tannerlinsley.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 31, 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 5014265:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query: basic-typescript Configuration

@TkDodo TkDodo marked this pull request as draft August 31, 2021 20:37
add a test for refetch interval function
treat refetchInterval of 0 the same as false (no interval)
pass the whole query as second argument to refetchInterval function. errors can still be accessed via `query.state.error`, and it will give us access to the queryKey as well (useful for setting up the interval globally in defaultOptions).

separating out `data` as separate parameter still makes sense because it will be the observer result (possibly transformed by `select`), while `query.state.data` will be the raw data
always pass nextInterval to updateRefetchInterval
use false as a fallback instead of zero
@TkDodo TkDodo merged commit 9e414e8 into TanStack:master Oct 2, 2021
@TkDodo TkDodo deleted the feature/refetchInterval-function branch October 2, 2021 16:16
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 3.25.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

2 participants