Question: useQuery
and async
#1002
-
The definition of useQuery seemingly converts asynchronous functions into a synchronous one. How does that work? Does it cause blocking in frontend? How to access the promise instead? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Good question! The short answer is because it use React Suspense (concurrent mode). So while the network request is inflight, it triggers suspense which wall cause the fallback component on the nearest So the component render basically stops at the Does that makes sense? |
Beta Was this translation helpful? Give feedback.
Good question! The short answer is because it use React Suspense (concurrent mode).
So while the network request is inflight, it triggers suspense which wall cause the fallback component on the nearest
<Suspense fallback={/*stuff*/}>
component.So the component render basically stops at the
useQuery
call until the promise is resolved. Once resolved, then the component will fully render.Does that makes sense?