-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getQueryData suddenly returns undefined for a query even though no update to query data has occurred #7110
Comments
can't access that sandbox, please make it public |
Same problem here @TkDodo unfortunately. In svelte using:
I'll try to create a reproduction soon. |
@LukasDeco do you have any work-around? Any fix? |
I don't know if this is the same issue I'm facing right now. I opened #7204 with a reproduction. @LukasDeco your reproduction is 404. |
gonna close this because the reproduction is inaccessible. |
@frederikhors I just had to add some extra logic to catch if it went undefined and then throw it in a useState. It's a bit of a mess. |
@TkDodo I changed to public |
@TkDodo the example is updated to be working now: https://codesandbox.io/p/sandbox/react-query-bug-qw336y?file=%2Fsrc%2FApp.js%3A14%2C26 |
Describe the bug
In a React component, calling queryClient.getQueryData for a specific query is suddenly returning undefined after previously returning data during subsequent renders, despite no new calls to queryClient.setQueryData for that query. This behavior is observed even when console logging confirms that setQueryData has not been invoked for the affected query, so there is no clear reason why it would turn undefined suddenly.
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/react-query-bug-qw336y?file=%2Fsrc%2FApp.js
Steps to reproduce
Expected behavior
As a user, I expected getQueryData to not return some new value unless something happened to update that query. If this is something to do with a cache becoming stale, that is something I didn't see in the docs.
How often does this bug happen?
Often
Screenshots or Videos
No response
Platform
Browser: Chrome
Tanstack Query adapter
react-query
TanStack Query version
5.24.1
TypeScript version
5.2.2
Additional context
No response
The text was updated successfully, but these errors were encountered: