Skip to content

RTKQ: useLazyQuery + refetchOnMountOrArgChange #3898

Open
@sucat

Description

@sucat

Hey!
useQuery hook accepts refetchOnMountOrArgChange option. I find it very helpful when I need to refetch the data from the API after some time passed.

I'd like to achieve exact same results but with useLazyQuery:

  1. There is a component rendered with button.
  2. When button is clicked - call trigger from useLazyQuery.
  3. When the button is clicked again within 5s - serve the data from cache
  4. When the button is clicked after 5s - make API request

Is it currently achievable? I tried many things but couldn't get it working like that with useLazyQuery hook.

Thanks!

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