React Suspense is not working up with convex
I wrapped my client parent component with suspense, the parent client component is using useQuery hook and and based on state the query is changing.
I want to ask am I doing it in a wrong way cuz my suspense fallback is clearing not showing up
This how i am wrapping my parent component
6 Replies
If it helps my parent component ie "WeekHeader" has a client component that is also using useQuery to fetch info based on the prop passed from parent
You need to implement a version of useQuery that uses Suspense. The built-in one does not use Suspense, and returns
undefined
while the query is loading.@Abhishek any sample or code example you have, It will be of a great help to speed up my progress thanks
Unfortunately, React docs state "Suspense-enabled data fetching without the use of an opinionated framework is not yet supported". You'll need to switch to React canary releases and use the experimental
use()
API to make this happen.
If you're using Next, though, they may provide a way. I'm not sure how Next implements suspense enabled data fetching or whether it's compatible with a custom hook.This is an example that also used SSR in Remix, you can get rid of the SSR part. Right now suspense is just throwing a promise:
throwing a promise 🤦♂️