react-query-usequery-patterns

Guide useQuery architecture in React with TanStack Query patterns.

1|Updated Nov 26, 2014
One-click install
npx skills add https://github.com/tianhuil/dotfiles --skill react-query-usequery-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-query-usequery-patterns
Source: https://github.com/tianhuil/dotfiles/tree/main/home/.config/opencode/skills/react-query-usequery-patterns
Command: npx skills add https://github.com/tianhuil/dotfiles --skill react-query-usequery-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Streamlines and standardizes data fetching in React apps by teaching how to architect useQuery calls for maximum deduplication and portability.

Core Features & Use Cases

  • Co-located useQuery calls across components to ensure a single network request and shared cache
  • Custom hook patterns to centralize query configuration and promote reuse
  • Use of select to minimize re-renders and optimize performance for specific UI slices

Quick Start

Provide a concise guide showing the recommended useQuery patterns for React components to maximize deduplication.

Frequently Asked Questions about react-query-usequery-patterns

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

FAQPage Schema
How does useQuery deduplication work across multiple React components?

useQuery deduplication occurs when multiple React components use the same query key, allowing TanStack Query to share a single network request and cache across the component tree.

How do I create a custom hook for react-query to centralize configuration?

You can create custom hooks wrapping useQuery to centralize query configuration, promote configuration reuse, and maintain robust data fetching with minimal boilerplate across your application.

What's the best way to minimize re-renders with TanStack Query?

The best way to minimize re-renders is using the select option in useQuery to subscribe components only to specific UI slices, optimizing performance by preventing unnecessary component updates.

When should I use co-located queries instead of a centralized data fetching layer?

You should use co-located queries directly in components when you want maximum portability and automatic deduplication, trading off centralized control for robust, maintainable data fetching with less boilerplate.

Does TanStack Query support select-based data transformation for specific UI components?

Yes, TanStack Query supports the select option to perform data transformation, allowing each component to subscribe to specific slices of the cached data and significantly optimize rendering performance.