React Query
Guide for writing React Query hooks, mutation hooks, and query UI in this codebase. Use when creating or modifying useQuery/useMutation hooks, rendering query…
от vultisig★ 22 звезды на GitHub
Установить React Query в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
React Query Patterns
Custom types and utilities live in @lib/ui (lib/ui/query/).
Query Hook
import { useQuery } from '@tanstack/react-query'
export const useSomeQuery = () => {
const input = { id, network }
return useQuery({
queryKey: ['getSomething', input],
queryFn: () => getSomething(input),
})
}
- Query key is
[functionName, input]whenqueryFncalls another function with an input. - Include every variable the query depends on in the key.
- Export a
getXxxQueryKeyhelper when mutations need to invalidate or reset the query from elsewhere.
Resolved Data Hook
When a parent renders children only after a query succeeds (via MatchQuery) and child components need to access the resolved data, provide a companion hook. Only create this hook when there are actual consumers -- knip will flag unused exports.
export const useSomeQuery = () => useQuery({ ... })
export const useSomeData = () => {
const { data } = useSomeQuery()
return ensurePresent(data, 'some query data')
}
Query UI Rendering
Use MatchQuery from @lib/ui/query/components/MatchQuery for loading/error/success states. Never write manual if (isLoading) / if (error) checks.
import { MatchQuery } from '@lib/ui/query/components/MatchQuery'
<MatchQuery
value={query}
pending={() => <Spinner />}
error={(e) => <ErrorMessage error={e} />}
success={(data) => <DataView data={data} />}
/>
All render props default to () => null. There is also an inactive prop for queries that haven't started.
Mutation Hook
import { useMutation } from '@tanstack/react-query'
import { useRefetchQueries } from '@lib/ui/query/hooks/useRefetchQueries'
export const useSomeMutation = () => {
const refetchQueries = useRefetchQueries()
return useMutation({
mutationFn: async () => {
// perform mutation
},
onSuccess: () => {
refetchQueries(getTransactionsQueryKey({ ... }))
},
})
}
useRefetchQueries()from@lib/ui-- refetches multiple query keys in one call.- Always invalidate all queries whose data is affected by the mutation.
Utilities (@lib/ui)
Query option presets to spread into useQuery:
noRefetchQueryOptions-- disables refetch on mount, window focus, and reconnect.persistQueryOptions-- marks query for localStorage persistence.pollingQueryOptions(intervalMs)-- enables periodic refetching at the given interval.
Hooks for composing queries:
useCombineQueries({ queries, joinData, eager? })-- merges multiple queries into one. Accepts an array of queries or a record of named queries.eager: true(default) returns partial data;eager: falsewaits for all.useTransformQueryData(query, transform)-- derives new data from a single query.
Types:
Query<T, E>--{ data: T | undefined, isPending: boolean, error: E | null }EagerQuery<T, E>--{ data: T | undefined, isPending: boolean, errors: E[] }inactiveQuery-- constant for idle state.pendingQuery-- constant for pending state.getResolvedQuery(data)-- creates a resolvedQuery<T>from data.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл React Query?
Guide for writing React Query hooks, mutation hooks, and query UI in this codebase. Use when creating or modifying useQuery/useMutation hooks, rendering query states, combining or transforming queries, invalidating caches, or working with `@lib/ui` query utilities.
Как установить скилл React Query?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл React Query запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…