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#
- Go to the MWE
- Click "Refetch", and note that "isFetching: true" is displayed
- Before the query ends (you have 5 seconds), click "Manually update data"
- "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
I decided to fix this for v4 only because a bunch of things have changed around setQueryData in v4.