Skip to content

Query with { notifyOnChangedProps: [] } still re-renders on cache update. #4043

@chekrd

Description

@chekrd

Describe the bug

We need to prevent a query from re-rendering. We are setting query options { enabled: false, notifyOnChangedProps: [] } once the query is fetched. We mutate the same data in another component. Despite the options being set, the query still re-renders.

Your minimal, reproducible example

https://codesandbox.io/s/react-query-forked-8gly22?file=/src/App.tsx

Steps to reproduce

  1. Open codesandbox console.
  2. Type something into the input and press Mutate todo button.
  3. See console output, no log should occur as the component should not re-render.

Expected behavior

Query with options.notifyOnChangedProps set to an empty array does not re-render.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Safari 15.6, Chrome 104

react-query version

v4.1.3

TypeScript version

v4.7.4

Additional context

No response

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