Problem: React Query’s useSuspenseQuery displays the Suspense fallback...


Problem: React Query’s useSuspenseQuery displays the Suspense fallback anytime the query key changes. What if you want to only show the fallback the first time the query fires?

Solution: useSuspenseQueryDeferred.

The custom hook below only displays the Suspense fallback the first time the query fires. Otherwise, it shows the stale data until the query completes.

More details: https://www.teemutaskula.com/blog/exploring-query-suspense#adding-types

View original on X