Suspense with TRPC server query
Hi, I'm trying to query some data using TRPC in my server component. However, when using React.Suspense, I never see a fallback (even if I disable cache and use a slow 3G connection). I'm not sure if this is not the right pattern or if I just can't test it properly.
4 Replies
Any luck with this mate?
One option would be to check query.isFetched, and return a skeleton if it isn’t.
Try const { buildings, isLoading } = await api.building....
then before return statement:
isLoading ? return <div>Loading</div> : return <>// your component </>
you just have to remove the
await
. here is an example: https://github.com/t3-oss/create-t3-turbo/blob/main/apps/nextjs/src/app/page.tsxGitHub
create-t3-turbo/apps/nextjs/src/app/page.tsx at main · t3-oss/creat...
Clean and simple starter repo using the T3 Stack along with Expo React Native - t3-oss/create-t3-turbo