The TanStack Query loading trap you should avoid Ever seen a loading spinner that never stops when you're offline? This usually happens when you rely only on isPending. What’s happening behind the scenes: - First load (no cache) + user goes offline - Query gets paused, not failed: isPending = true, fetchStatus = 'paused' - UI keeps showing a spinner Problem: Checking only isPending results in the user being stuck on a loader with no explanation. Solution 1: Check both isPending and fetchStatus. This allows you to show a specific "Offline" message instead of a generic spinner. Solution 2: Control network behavior by updating global config: networkMode: 'always' This forces queries to run even when offline (no pause state) It is a small detail, but handling these edge cases makes a huge difference in providing a polished user experience. Thanks to JavaScript Mastery, Hitesh Choudhary, RoadsideCoder.com, Traversy Media, freeCodeCamp for sharing such valuable content for Frontend production-grade applications. #TanStackQuery #ReactQuery #WebDevelopment #Frontend #JavaScript #ReactJS
Really good point I think combining this with cached/stale data strategies makes it even better, so instead of a loader, users still see previous data when offline. Handling these edge cases properly is what makes apps feel reliable and polished
This is insightful, I've been looking for ways to handle this properly
Great info!!
Thanks for thinking of us! We're grateful to have your support! 🔥