T
TanStack3y ago
metropolitan-bronze

Query.isEnabled?

I have a hook that handles a bunch of stuff including using the query and it passes in enabled and the custom hook will return the query object. I was showing a loading spinner if the query is loading but that became a problem when I initially set the query enabled to false, it says it's still loading. How can I tell if the query is enabled or not? Is there no way to tell if the query is 'enabled' from the query object? I will have to also return whether the query is enabled or not from my custom hook? Thanks
2 Replies
fair-rose
fair-rose3y ago
Hi. This is the expected behavior since v4. « Loading » means « no data ». So it is fine to be true when not enabled. For your usecase, you could use isInitialLoading
fair-rose
fair-rose3y ago
Migrating to React Query 4 | TanStack Query Docs
Breaking Changes v4 is a major version, so there are some breaking changes to be aware of:

Did you find this page helpful?