You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seemed to be working for us, but we started running into issues where dependent queries were infinitely refetching data, or other similar strange errors. After more investigation, we found this issue. And started restructuring with .updateOptions().
This adds a lot of extra and duplicate code though, as we now need to pull in the query key formatter, enabled condtions and select functions into each call-site, like so:
Additionally, we seem to be running into issues with dependent queries misfiring because the initial queries report stale data and isSuccess, isLoading etc. still have stale values, such as:
This causes issues with the detailQuery, because fooBarQuery.isSuccess is still true despite the queryKey being updated to something that hasn't been fetched and isn't in the cache.
Can someone provide a comprehensive example utilizing dependent queries with reactive values?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Using useQuery with dynamic/reactive values
We just had to rearchitect our whole app after discovering that reactivity with
useQuery
doesn't work how we expected.Our queries were structured something like this:
And we were using them in the following way:
This seemed to be working for us, but we started running into issues where dependent queries were infinitely refetching data, or other similar strange errors. After more investigation, we found this issue. And started restructuring with
.updateOptions()
.This adds a lot of extra and duplicate code though, as we now need to pull in the query key formatter, enabled condtions and select functions into each call-site, like so:
Additionally, we seem to be running into issues with dependent queries misfiring because the initial queries report stale data and
isSuccess, isLoading
etc. still have stale values, such as:This causes issues with the
detailQuery
, becausefooBarQuery.isSuccess
is still true despite the queryKey being updated to something that hasn't been fetched and isn't in the cache.Can someone provide a comprehensive example utilizing dependent queries with reactive values?
Beta Was this translation helpful? Give feedback.
All reactions