React Idioms and Patterns

Generate idiomatic React 18+ components and hooks with TanStack Query or SWR.

150|48|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/irahardianto/awesome-agv --skill react-idioms-and-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: React Idioms and Patterns
Source: https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/react-idioms
Command: npx skills add https://github.com/irahardianto/awesome-agv --skill react-idioms-and-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves inconsistent or non-idiomatic React implementations that lead to brittle components, avoidable performance issues, and hard-to-maintain state and error handling.

Core Features & Use Cases

  • Functional component patterns: Prefer composition patterns and typed props with predictable defaults, avoiding class components in new code.
  • Hook correctness: Use custom hooks for reusable logic, apply memoization only when profiling indicates issues, and always implement effect cleanup for subscriptions and abortable work.
  • Pragmatic state and error handling: Treat server state with TanStack Query/SWR (not global state), manage client state only where appropriate, and use error boundaries and query-level error UI.
  • Use case: When building a task dashboard with lists, forms, and API-driven server state, this Skill helps ensure your components are resilient, accessible, and maintainable from the first iteration through production.

Quick Start

Use the React Idioms and Patterns Skill to refactor an existing React feature so it follows functional composition, hook best practices, server-state handling with TanStack Query/SWR, and robust error UI.

Frequently Asked Questions about React Idioms and Patterns

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

FAQPage Schema
How do I avoid data fetching anti-patterns in useEffect for React server state?

To avoid data fetching anti-patterns in useEffect, manage server state using TanStack Query or SWR instead of local component state. This prevents brittle components by handling caching, synchronization, and query-level error UI robustly.

What is the best way to structure custom hooks and functional components in React 18?

The best way to structure custom hooks and functional components is to use composition patterns with typed props and predictable defaults. Encapsulate reusable logic in hooks and always implement effect cleanup for subscriptions and abortable work.

When should I use memoization in React components?

You should apply memoization in React components only when profiling indicates measurable performance issues. Avoid premature optimization in functional components and rely on predictable composition patterns for maintainability.

How do I handle errors resiliently in React applications with server state?

Handle errors resiliently by implementing error boundaries for component-level crashes and query-level error UI for server state. Treat server state separately from global client state using TanStack Query or SWR to isolate failures.

Does this React patterns approach work for refactoring existing class components?

Yes, this approach works for refactoring existing class components by replacing them with functional components. It leverages hook correctness and composition patterns to improve reliability and maintainability from the first iteration through production.

How do I manage effect cleanup for subscriptions in React hooks?

Manage effect cleanup by returning a cleanup function from your useEffect hook to cancel subscriptions and abortable work. This ensures reliable client state management and prevents memory leaks during component unmount.