When to use `useQuery` vs `useSuspenseQuery` with NextJS?
I looked trough the documents trying to find some details about the differences between
useQuery
and useSuspenseQuery
hooks, but other than the fact that the status
is always success and there's no error obbject in the suspense version of the hook, I don't understand the main differences between the two.
Can anyone explain to me:
- Where and When do I want to use the suspense version of the hook?
- Is it okay to use the "normal" non-suspense version of the hook?2 Replies
wise-white•2y ago
suspense integrates with suspense of react. You need suspense boundaries and error boundaries, and potentially transitions.
see: https://react.dev/reference/react/Suspense
– React
The library for web and native user interfaces
typical-coralOP•2y ago
Okay, but I still am a bit confused about the use cases of it. Should we be moving more towards usage of suspense version as the default, or should we use it interchangeably with the regular "useQuery" hook?
And if we're to use it interchangeably, then in which scenarios would we want to use one over the other, and vice versa?
Edit: And how do they differ (if at all) when using to display data that we modified trough mutations?