practical-react-query

Comprehensive guide to React Query (TanStack Query) covering data fetching, caching, mutations, error handling, TypeScript, testing, and advanced patterns. Use when working with React Query, TanStack Query, or async state management in React applications.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "practical-react-query" with this command: npx skills add mhdcodes/react-query-skill/mhdcodes-react-query-skill-practical-react-query

React Query Guide

This skill provides comprehensive guidance on React Query (TanStack Query) for building modern React applications with async state management.

When to Use This Skill

Use this skill when you need help with:

  • Setting up and configuring React Query
  • Data fetching, caching, and synchronization
  • Mutations and optimistic updates
  • Error handling and retry strategies
  • TypeScript integration
  • Testing React Query code
  • Performance optimization
  • Advanced patterns and best practices

Topics

Read the relevant reference file based on what you need:

Getting Started

TopicDescriptionFile
Practical React QueryCore concepts, defaults, query keys, custom hooks01-practical-react-query.md
Why Use React QueryBenefits and reasons to adopt React Query23-why-use.md
When Not NeededSimpler alternatives when React Query is overkill21-when-not-needed.md

Core Concepts

TopicDescriptionFile
Query KeysStructuring keys for caching, refetching, invalidation08-query-keys.md
Query Function ContextExtract params from query keys09-query-function-context.md
Query Options APICode organization and type inference24-query-options-api.md
State ManagerReact Query as an async state manager11-state-manager.md

Data Handling

TopicDescriptionFile
Data TransformationsTransform data in queryFn, render, or select02-data-transformations.md
Placeholder & Initial DataPre-fill cache, improve UX10-placeholder-initial-data.md
Seeding CachePre-populate query cache18-seeding-cache.md
SelectorsAdvanced selector patterns for partial subscriptions28-selectors.md

Mutations & Updates

TopicDescriptionFile
MutationsuseMutation, optimistic updates, invalidation13-mutations.md
Auto InvalidationAutomatic query invalidation patterns25-auto-invalidation.md
Concurrent Optimistic UpdatesHandle concurrent optimistic updates27-concurrent-optimistic.md

State & Error Handling

TopicDescriptionFile
Status ChecksLoading states, background errors04-status-checks.md
Error HandlingError boundaries, retry strategies12-error-handling.md

Performance

TopicDescriptionFile
Render OptimizationsnotifyOnChangeProps, tracked queries, structural sharing03-render-optimizations.md
Infinite QueriesPagination, infinite scroll26-infinite-queries.md

Integration

TopicDescriptionFile
TypeScriptGenerics, type narrowing, enabled option typing06-typescript.md
Type SafetyAdvanced TypeScript patterns20-type-safe.md
React RouterData loading, navigation integration17-react-router.md
React ContextCombining with React Context22-context.md
WebSocketsReal-time data sync07-websockets.md
FormsForm integration, handling form state15-forms.md

Advanced

TopicDescriptionFile
InternalsQueryClient, QueryCache, QueryObserver19-internals.md
Offline SupportPersistence, offline mutations14-offline.md
TestingMocking network requests, MSW integration05-testing.md
FAQsFrequently asked questions16-faqs.md

Quick Reference

Basic Query

import { useQuery } from "@tanstack/react-query";

function Component() {
  const { data, isLoading, error } = useQuery({
    queryKey: ["todos"],
    queryFn: fetchTodos,
  });
}

Basic Mutation

import { useMutation, useQueryClient } from "@tanstack/react-query";

function Component() {
  const queryClient = useQueryClient();

  const mutation = useMutation({
    mutationFn: addTodo,
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ["todos"] });
    },
  });
}

Query Client Setup

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient();

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <YourApp />
    </QueryClientProvider>
  );
}

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Content Collector

个人内容收藏与知识管理系统。收藏、整理、检索、二创。 Use when: (1) 用户分享链接/文字/截图并要求保存或收藏, (2) 用户说"收藏这个"/"存一下"/"记录下来"/"save this"/"bookmark"/"clip this", (3) 用户要求按关键词/标签搜索之前收藏的内容, (4) 用...

Registry SourceRecently Updated
Coding

Github Stars Tracker

GitHub 仓库 Stars 变化监控与通知。追踪指定仓库的 star 增长、fork 变化,发现新趋势。适合开发者关注项目动态。

Registry SourceRecently Updated
Coding

RabbitMQ client guide for Tencent Cloud TDMQ

RabbitMQ 客户端代码指南。当用户需要编写、调试或审查 RabbitMQ 应用代码时使用。涵盖:用任意语言(Java/Go/Python/PHP/.NET)写生产者或消费者;排查连接暴增、消息丢失、Broken pipe、消费慢、漏消费等客户端问题;审查 spring-boot-starter-amqp、a...

Registry SourceRecently Updated