Skip to content
Source
Sign inSign up
TanStack/query

Referencial stability lost when using react-compiler #9571

Send to my agent
ClosedTheSisb(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

Tanstack query goes to great lengths to make sure the data object returned by a useQuery is stable, so that when it is used as a dependency in a useMemo, it doesn't cause the useMemo to run on every re-render.

That all goes out the window when using react-compiler. I made a repro and attached it to this ticket. There are also issues where select runs more than it should, but I don't provide a repro for that here.

I also made an issue on the react-compiler repo: https://github.com/facebook/react/issues/34211

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-ucqzqtvo?file=vite.config.ts

Steps to reproduce

See stackblitz

Expected behavior

the useMemo should not run on every re-render, only when data actually changes

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • all browsers and platforms

Tanstack Query adapter

react-query

TanStack Query version

5.85.3

TypeScript version

^5.6.3

Additional context

No response

  1. TkDodo closed this

  2. TkDodo added labelsinvalid

  3. TkDodo added labelsworks as designed

Sign in to join this conversation.