Skip to content

Disabled query gets called anyway by the refetch feature #635

@GuillaumeSpera

Description

@GuillaumeSpera

Describe the bug
I have some disabled queries awaiting for some change on my components.
And even if the value doesn't change, the queryFn is called at each refetchInterval.

To Reproduce

const [neverUpdatedValue] = React.useState(null);
useQuery({
    queryKey: ["test", neverUpdatedValue],
    queryFn: (key, value) => {
        console.log(key, value);
        return Promise.resolve();
    },
    config: {
        enabled: !!neverUpdatedValue,
        refetchInterval: 2000
    }
});

I set up a sandbox derived from your "Basic" example :
https://codesandbox.io/s/busy-moon-pon1t?file=/src/index.js

The refretchInterval triggers the queryFn even if it is disabled.

Expected behavior
Do not trigger the queryFn.

Desktop (please complete the following information):

  • Version 2.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions