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
I answered on the compiler issue: