isLoading defaults to true?
I create a useQuery, enabled set to false. I want fetching to occur on demand, by clicking a button. Why is "isLoading" set to true initially?
https://codesandbox.io/s/epic-lucy-ppu5x6?file=/src/App.js:1849-1943
amivag
CodeSandbox
epic-lucy-ppu5x6 - CodeSandbox
epic-lucy-ppu5x6 by amivag using @tanstack/react-query, @tanstack/react-query-devtools, axios, react, react-dom, react-scripts
6 Replies
dependent-tan•3y ago
This is the expected behaviour. There's an explanation and suggestion on what to do in the version 3 to version 4 migration guide. See: https://tanstack.com/query/v4/docs/react/guides/migrating-to-react-query-4#the-idle-state-has-been-removed and https://tanstack.com/query/v4/docs/react/guides/queries#why-two-different-states
sensitive-blueOP•3y ago
Thank you. Not super happy about this, makes no semantic sense... thanks for the help!
dependent-tan•3y ago
The
status gives information about the data: Do we have any or not?
The fetchStatus gives information about the queryFn: Is it running or not?
This is from the documentation and is the right mental model to have with the new version in my opinion.
No worries, happy to help :reactquery:metropolitan-bronze•3y ago
Hi, yes mainly a semantic issue here. But no as easy as it seems to tackle. You could have a look at the different discussions about it here: https://github.com/TanStack/query/discussions/4252#discussioncomment-4583653
GitHub
v5 Roadmap 🗺 · Discussion #4252 · TanStack/query
TanStack Query v5 Roadmap Update: The roadmap is now a milestone: https://github.com/TanStack/query/milestone/2 This is a first draft of what a v5 could look like in terms of breaking changes. Noth...
fair-rose•3y ago
we'll "fix it" in v5
we will do the rename to
pending as described in the roadmapsensitive-blueOP•3y ago
Thank you!