Skip to content
Source
Sign inSign up
TanStack/query

setQueryData incorrectly sets isFetching to false #3594

Send to my agent
Closedlgenzelis(GitHub profile, opens in a new tab) opened this issue 2 comments

Describe the bug

If setQueryData is invoked while a query is fetching, isFetching automatically goes to false.

Quoting @TkDodo (see his comment in #3579 ), when setQueryData is called

only the status, data and dataUpdatedAt fields should be set

Your minimal, reproducible example

https://codesandbox.io/s/setquerydata-and-isfetching-bug-gck1zp?file=/src/App.js

Steps to reproduce

  1. Go to the MWE
  2. Click "Refetch", and note that "isFetching: true" is displayed
  3. Before the query ends (you have 5 seconds), click "Manually update data"
  4. "isFetching: false" is displayed, even though the query is still being fetched 🐛🐛🐛

Expected behavior

Calling setQueryData shouldn't change the value of isFetching

How often does this bug happen?

Every time

Screenshots or Videos

https://user-images.githubusercontent.com/4582440/167303377-e254b757-d84a-480f-9cdf-0abab3227f9a.mov

Platform

  • OS: MacOs
  • Browser: Chrome
  • Version: 100

react-query version

3.39.0 and also 4.0.0-beta.9

TypeScript version

No response

Additional context

No response

  1. TkDodo added labelsbug

  2. TkDodo added labelsv4

  3. I decided to fix this for v4 only because a bunch of things have changed around setQueryData in v4.

  4. TkDodo closed this

  5. :tada: This issue has been resolved in version 4.0.0-beta.11 :tada:

    The release is available on:

    Your semantic-release bot :package::rocket:

  6. tannerlinsley added labelsreleased on @beta

Sign in to join this conversation.