Dev.to
5/13/2026

Why Your Nextjs UI Flickers: TanStack Query vs useEffect
Short summary
useEffect-based data fetching causes UI flicker by resetting loading states on every refetch, while TanStack Query fetches in the background and keeps previous data visible. Performance isn't just about raw speed—it's about maintaining visual stability and smooth interface behavior during updates. The demo and code examples show how the right data-fetching pattern dramatically improves perceived stability.
- •useEffect resets loading state on refetch, causing flicker and layout shifts
- •TanStack Query keeps previous data visible while fetching in background
- •UI stability during updates matters as much as raw fetch speed
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



