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

[react-query][Bug?]When invalidating useSuspenseQuery queries with invalidateQueries, the refetch process does not run. #7558

Closed
yanachuwan9sm opened this issue Jun 13, 2024 · 1 comment
Labels
invalid This doesn't seem right

Comments

@yanachuwan9sm
Copy link

yanachuwan9sm commented Jun 13, 2024

Describe the bug

When the complete button is pressed, the query is disabled and getTodo is not executed when it should be fetching data again in the background. (Check out codesandbox!)

Your minimal, reproducible example

codesandbox

Steps to reproduce

1 Click on the complete button
2 Please check the console in DevTools

Expected behavior

I want the following console log to be displayed when the complete button is pressed.

If the query is currently being rendered via useQuery or related hooks, it will also be refetched in the background
https://tanstack.com/query/latest/docs/framework/react/guides/query-invalidation

### getTodo
------------------------------------------------------------------------
### completeTodo
------------------------------------------------------------------------
### getTodo
------------------------------------------------------------------------

How often does this bug happen?

Every time

Screenshots or Videos

2024-06-13.11.53.21.mov

Platform

N/A

Tanstack Query adapter

react-query

TanStack Query version

v5.28.6

TypeScript version

v4.4.4

Additional context

No response

@yanachuwan9sm yanachuwan9sm changed the title When invalidating useSuspenseQuery queries with invalidateQueries, the refetch process does not run. [react-query][Bug?]When invalidating useSuspenseQuery queries with invalidateQueries, the refetch process does not run. Jun 13, 2024
@TkDodo
Copy link
Collaborator

TkDodo commented Jun 16, 2024

you're not importing getTodoQueryKey in the file that executes the mutation. The TypeScript error you see is in your sandbox is there for a reason ...

https://codesandbox.io/p/sandbox/usesuspensequery-refetch-example-forked-8fwz68?file=%2Fsrc%2FTodo%2Fuse-complite-todo.ts%3A4%2C26

@TkDodo TkDodo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2024
@TkDodo TkDodo added the invalid This doesn't seem right label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants