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
Hey, I'm struggling a bit to find a good way to structure and use react-query for a specific part in my code.
I have 2 "gates" I want my app to go through before my screens and features get executed.
A gate that fetches data about a user, showing a loader while fetching, and then passing the user to a context. That way user will always be defined after I "pass" the gate.
A gate that fetches a healthy chunk of data based on the user that is already defined. Same thing about showing a loader until the data is fetched, but this time I can't (or don't want to) save it in a context because it is a fairly big chunk of data.
The question is how do I indicate to all the code that comes after passing gate 2, that the chunk of data I loaded there is actually defined?
I'm using V5 and know of Suspense, but my team lead prefers I don't use it (says it might be prone to leaks and that throwing Promises might be odd).
I could also assert it as defined, but if there's any other recommended method you might suggest I'd much prefer it.
If perhaps there are resources/examples you might conjure up that seem similar to the structure I'm looking for I'd also appreciate links.
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
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I'm struggling a bit to find a good way to structure and use
react-query
for a specific part in my code.I have 2 "gates" I want my app to go through before my screens and features get executed.
user
will always be defined after I "pass" the gate.The question is how do I indicate to all the code that comes after passing gate 2, that the chunk of data I loaded there is actually defined?
I'm using V5 and know of Suspense, but my team lead prefers I don't use it (says it might be prone to leaks and that throwing Promises might be odd).
I could also assert it as defined, but if there's any other recommended method you might suggest I'd much prefer it.
If perhaps there are resources/examples you might conjure up that seem similar to the structure I'm looking for I'd also appreciate links.
Beta Was this translation helpful? Give feedback.
All reactions