react-patterns

Apply modern React patterns for component design, hooks, TypeScript props, and testing.

Updated Aug 30, 2024
One-click install
npx skills add https://github.com/jfrometa/esquizo --skill react-patterns-jfrometa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-patterns
Source: https://github.com/jfrometa/esquizo/tree/main/.agent/skills/react-patterns
Command: npx skills add https://github.com/jfrometa/esquizo --skill react-patterns-jfrometa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured approach to applying modern React patterns and principles, helping teams build robust, maintainable UIs with improved performance and scalability.

Core Features & Use Cases

  • Component Design Principles: server, client, presentational, and container components to separate concerns and improve testability.
  • Hook Patterns: guidance on when to extract custom hooks (useLocalStorage, useDebounce, useFetch, useForm), top-level hook usage, naming conventions (prefix with use), and cleanup on unmount.
  • State Management & Architecture: strategies for local state, context, and server/state solutions like React Query or SWR, plus guidelines for appropriate placements.
  • TypeScript Patterns: props typing with interfaces or types, common types like ReactNode, Event handlers, and refs.
  • Testing Principles: unit, integration, and E2E.
  • Anti-Patterns: avoid prop drilling, giant components, overusing useEffect, premature optimization, and using index as key.
  • Real-world Use: apply these patterns to build a small design system or feature module with reusable components.

Quick Start

Create a new React project and implement a small UI demonstrating the patterns described in this Skill. For example, build a dashboard with server data, a few reusable presentational components, and a custom hook like useForm to manage a simple form.

Frequently Asked Questions about react-patterns

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

FAQPage Schema
What are the best React design patterns for scalable component architecture?

To avoid prop drilling in React applications, extract custom hooks like useLocalStorage or useFetch, and apply state management strategies using context or server-state solutions like React Query to place state appropriately.

How do I type React component props with TypeScript correctly?

To type React component props with TypeScript, define props using interfaces or types, and utilize common types like ReactNode, Event handlers, and refs to ensure consistent typing across your frontend architecture.

When should I extract a custom hook in React?

React anti-patterns to avoid include prop drilling, building giant components, overusing useEffect, premature optimization, and using index as key, which degrade performance and maintainability.

How do I manage server state in React without overusing useEffect?

To manage server state in React without overusing useEffect, adopt dedicated server and state management solutions like React Query or SWR, which handle data fetching, caching, and synchronization more robustly.