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

queryClient.refetchQueries(queryKey) refetches disabled queries #4331

Closed
yegao opened this issue Oct 17, 2022 · 4 comments
Closed

queryClient.refetchQueries(queryKey) refetches disabled queries #4331

yegao opened this issue Oct 17, 2022 · 4 comments

Comments

@yegao
Copy link

yegao commented Oct 17, 2022

Describe the bug

The official documentation describing the enabled option :

When enabled is false:
...
The query will ignore query client invalidateQueries and refetchQueries calls that would normally result in the query refetching.

But In my project queryClient.refetchQueries(queryKey) refetches disabled queries。

Your minimal, reproducible example

none

Steps to reproduce

  1. Create a query with useQuery and set enabled option to false.
  2. Create a queryClient with useQueryClient.
  3. Invalidate this query with refetchQueries.

Expected behavior

The disabled queries (enabled: false) would not refetch when I use refetchQueries

How often does this bug happen?

No response

Screenshots or Videos

No response

Platform

OS: macOs
Browser: Not related

react-query version

^3.39.2

TypeScript version

^4.7.4

Additional context

No response

@TkDodo
Copy link
Collaborator

TkDodo commented Oct 17, 2022

This should be fixed in v4:

@TkDodo TkDodo closed this as completed Oct 17, 2022
@LetItRock
Copy link

hey @TkDodo! 👋 is there a workaround for this bug in v3?

@TkDodo
Copy link
Collaborator

TkDodo commented Dec 18, 2022

we haven't back-ported the fix to v3. Is there anything stopping you from upgrading to v4 ?

@LetItRock
Copy link

@TkDodo I'm not sure how much effort it might be and how many issues after it might bring. I'll go through the migration guide first then. But yeah, we would like to migrate anyway.

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

No branches or pull requests

3 participants