Skip to content

Infinite renders when using output of useQueries in useEffect dependency array #3049

@connorch

Description

@connorch

Describe the bug
When using the output of useQueries in the dependency array of a useEffect, the containing component will rerender infinitely. This bug seems to have been introduced in v3.9.0 and exists in all later versions.
Please see the Codesandbox I created below and change the version of react-query from 3.8.3 to any later version.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/wild-dust-p7swc?file=/src/QueryExample.js
  2. Change the react-query version from v3.8.3 to v3.9.0 or greater to see the issue. (Warning, might freeze your browser due to infinite rerenders)

Expected behavior
Expect the results of v3.8.3 and lower, where the useEffect is only called once when needed.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome - Version 96.0.4664.55 (Official Build) (arm64)
  • Version: >v3.9.0

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