Skip to content
Source
Sign inSign up
TanStack/query

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

Send to my agent
Closedyanachuwan9sm(GitHub profile, opens in a new tab) opened this issue 1 comment

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

https://github.com/TanStack/query/assets/95360878/ab7e6b5b-a08d-4dfc-933a-7fbabe9bc140

Platform

N/A

Tanstack Query adapter

react-query

TanStack Query version

v5.28.6

TypeScript version

v4.4.4

Additional context

No response

  1. 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

  2. TkDodo closed this

  3. TkDodo added labelsinvalid

Sign in to join this conversation.