Skip to content

The refetch function returned from useQuery should have a cancelRefetch option #1662

@ashwinGokhale

Description

@ashwinGokhale

Describe the bug
This is related to a question I had asked previously. The refetch function returned from useQuery should have a cancelRefetch option exposed in the typescript typings. Currently this option is hard coded to true for the fetchNextPage and fetchPreviousPage methods in InfiniteQueryObserver. I think this should be exposed to users because it will allow users to tell react-query to cancel the previous query when refetching.

Current Behavior
Subsequent calls to the refetch() function will wait until the promise is settled to make a new network request.

Expected behavior
Subsequent calls to the refetch({cancelRefetch: true}) function will cancel the previous in-flight request and immediately refetch again. To fix this, the RefetchOptions typescript interface should have an additional property: cancelRefetch?: boolean;

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