query icon indicating copy to clipboard operation
query copied to clipboard

isLoading is true when the query is not enabled

Open mazenkhalil opened this issue 4 years ago • 2 comments

Describe the bug

With V3, when the query is disabled, isLoading resolves to false. Upon upgrading to V4, isLoading resolves to true when the query is disabled.

useQuery(
    ['key'],
    () =>
        API.get(`...`).then((res) => res.data)
    {
      enabled: false
    },
  );

Your minimal, reproducible example

NA

Steps to reproduce

  1. Create a query
  2. Set enabled = false
  3. observe isLoading value

Expected behavior

isLoading should resolve to false as the query is not enabled yet.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: MacOS
  • Version: 4.0.10
  • React Version: 17

react-query version

v4.0.10

TypeScript version

v4.7.4

Additional context

No response

mazenkhalil avatar Aug 11 '22 07:08 mazenkhalil

has been reported before, and it's a documented breaking change.

TkDodo avatar Aug 11 '22 07:08 TkDodo

For others who landed on this issue, here is the other thread: https://github.com/TanStack/query/issues/3975

anglee avatar Aug 15 '22 15:08 anglee