-
Describe the bugThe initial status value is "loading", this is a problem when initially the query is disabled and then enabled later on. Or when in some cases it will be enabled initially or disabled. I have a loading backdrop that depends on the status of the query, this will make it always shown, even if the query did not execute. Your minimal, reproducible exampleN/a Steps to reproducevar providerResult = useQuery( existing might be false/true depending on different scenarios. Expected behaviorI would expect to either have the old status "Idle" or add new status call it "initial" or the like. It does not make sense to have the intial status "loading" while the query did not execute at all. How often does this bug happen?None Screenshots or VideosNo response Platformany browser Tanstack Query adapterNone TanStack Query version4.35.7 TypeScript versionNo response Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
it is documented that it starts in https://tanstack.com/query/v4/docs/react/guides/dependent-queries#usequery-dependent-query
There won't be a 4th state because that complicates states for every case where you're not using In v5, the The flag you want to check for is |
Beta Was this translation helpful? Give feedback.
-
Thanks @TkDodo for your comprehensive feedback. I think fetchStatus will solve my problem. All I need is to know if the api is being called . |
Beta Was this translation helpful? Give feedback.
it is documented that it starts in
status: 'loading'
here:https://tanstack.com/query/v4/docs/react/guides/dependent-queries#usequery-dependent-query
There won't be a 4th state because that complicates states for every case where you're not using
enabled
. The rationale is documented here: https://tanstack.com/query/v4/docs/react/guides/queries#why-two-different-statesIn v5, the
loading
state is renamed topending
to make it less confusing.pending
can hopefully be better associated with th…