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
Whenever someId changes there will be a period where the component contains the old data from one hook and the new data from the other hook causing an inconsistent UI state.
So far I came up with this:
Use currentData for both, but this makes the UI very jumpy. The nice thing about working with hooks is that the data remains unchanged until the query is actually finished.
Create an endpoint that combines both. But it feels a bit redundant to create endpoints for every "view" in your app that combines data from multiple endpoints. And what if you need to fetch data from two different API's?
However this feels like such a common usecase that I feel like I might be overlooking a better way to do this.
And in the above example its just two simultaneous requests. What if you more complex requirements such as two simultaneous requests followed by another request and you want all of the data to be made available in the UI at once while still showing the old data in the meanwhile.
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
-
Does RTKQ offer any kind of mechanism for coupling the results of one query hook with another?
When you do:
Whenever
someId
changes there will be a period where the component contains the old data from one hook and the new data from the other hook causing an inconsistent UI state.So far I came up with this:
currentData
for both, but this makes the UI very jumpy. The nice thing about working with hooks is that thedata
remains unchanged until the query is actually finished.However this feels like such a common usecase that I feel like I might be overlooking a better way to do this.
And in the above example its just two simultaneous requests. What if you more complex requirements such as two simultaneous requests followed by another request and you want all of the data to be made available in the UI at once while still showing the old data in the meanwhile.
Beta Was this translation helpful? Give feedback.
All reactions