react-data-fetching

Implements React data fetching patterns with TanStack Query, SWR, and Suspense.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-data-fetching-tierone-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-data-fetching
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/react-data-fetching
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-data-fetching-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React applications often suffer from request waterfalls, redundant fetches, and uncached useEffect-based data loading that degrade performance and complicate state management. ## Core Features & Use Cases - Waterfall Elimination: Parallelize independent fetches with Promise.all and restructure parent-child fetching so components load data concurrently. - Caching and Deduplication: Replace raw fetch-in-effect with TanStack Query or SWR for automatic caching, deduplication, retries, and background revalidation. - Optimistic Updates and Prefetching: Implement instant UI feedback with optimistic mutations and prefetch data on hover or via route loaders before navigation. - Use Case: When reviewing a React component that fetches user data in useEffect and then passes it to a child that fetches again, apply these patterns to hoist both queries to the same level and cut load time in half. ## Quick Start Refactor this React component to use TanStack Query with parallel fetching and a Suspense boundary instead of useEffect-based loading.

Frequently Asked Questions about react-data-fetching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fetch data in React without useEffect?

Use a data fetching library like TanStack Query with the useQuery hook, which handles caching, deduplication, retries, and loading states automatically. Pass a queryKey and queryFn instead of managing fetch calls inside useEffect.

TanStack Query vs SWR for React data fetching?

TanStack Query offers more features including suspense queries, devtools, infinite queries, optimistic mutations, and offline support, making it the stronger choice for Vite apps. SWR is a lighter alternative covering deduplication, caching, and revalidation basics.

How do I fix request waterfalls in React components?

Hoist child queries to the same level as the parent so both fetch in parallel, or use Promise.all for independent async calls. Route-level loaders can also fetch all required data before the component renders.

Does TanStack Query work with React Suspense?

Yes, TanStack Query provides useSuspenseQuery, which integrates with Suspense boundaries so loading states are declared in the component tree instead of managed per component. SWR offers an equivalent suspense option.

How do I implement optimistic updates with TanStack Query?

Use useMutation with onMutate to cancel in-flight queries, snapshot the previous cache value, and setQueryData with the predicted result. Roll back in onError using the snapshot and invalidate the query in onSettled.

When should I use React.cache for data fetching?

Use React.cache in React Server Components to deduplicate identical async calls within a single server render, such as getSession called by multiple components. Pass primitive arguments like strings, since inline objects create new references and cause cache misses.