Replies: 1 comment 3 replies
-
nope.
yes. Please make sure that you have a stable query client: https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Not sure if this should be a bug report, but this is something we’re struggling in our application with. I cannot reproduce this behaviour yet and we can only observe it from our error tracking.
What is happening?
We pre-fetch all of our data and use a dedicated loading screen while our data is getting fetched. This works normally, so we can always assume that subsequent screens have all data present (= all data present in the cache). There are some occasions though, where this assumption do not hold: We see in our error tracking, that some users land on a screen after successful pre-fetching and the data from the cache is returned as
undefined
.A similar issue appeared recently which should make this more clear. We have a home screen, displaying some content of the user. We store all data of the user in user cache and use hooks to create derived states from it (in pseudo-code):
What happened now is that on our home screen we have multiple instances of the “derived data hook“, where the first one successfully returned its data and the second one returned
undefined
(our React tree in pseudo-code):It’s important to note that the user cache in the hook where we derive the data is not always returning
undefined
, it’s just in some occasions for some users I cannot boil down to a specific reproduction. As we assume data is present in the child component, our app might run into an error when data is not present.My question
Is it possible that a query has a populated cache, but is still returning
undefined
initially (even in just a first render cycle and the data is potentially returned in a second render cycle)?When I have multiple instances, shouldn’t all queries return either their data or all return
undefined
?Beta Was this translation helpful? Give feedback.
All reactions