Skip to content

Issue with react-query and react-router calling the query again before navigating away from the page. #2399

@Pau1fitz

Description

@Pau1fitz

To Reproduce
Steps to reproduce the behavior:
I am using react-query v.3.16.0 with react-router-dom. I am having an issue when I navigate from a component with a sibling component using match params.

For example I have a page with a list of Football Leagues (Leagues component in code sandbox) When I go to this page and navigate to an individual league if you check the console you can see that the useQuery gets recalled in the Leagues component gets called again, although it shouldn't as this component has unmounted and the individual League component is visible.
See codesanbox here which will demonstrate the problem more clearly.

Expected behavior
I would expect when I navigate to a component (League) that is not the component (Leagues) where the useQuery exists that that query should not be called again before navigating away from that component.

**Desktop **

  • OS: osx
  • Browser: chrome
  • Version: 91.0.4472.114

Let me know if any more information is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions