frontend-patterns

Implements React component, state management, performance, and accessibility patterns in TypeScript.

1|Updated Aug 31, 2026
One-click install
npx skills add https://github.com/gagandeepgill/puzzle-game --skill frontend-patterns-gagandeepgill
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: frontend-patterns
Source: https://github.com/gagandeepgill/puzzle-game/tree/main/.claude/skills/frontend-patterns
Command: npx skills add https://github.com/gagandeepgill/puzzle-game --skill frontend-patterns-gagandeepgill

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Frontend developers repeatedly solve the same problems—component composition, async data fetching, form validation, list performance, and accessibility—often with inconsistent or buggy implementations. This Skill provides proven, copy-ready React and TypeScript patterns so you avoid common pitfalls like infinite fetch loops, mutated arrays, and broken keyboard navigation. ## Core Features & Use Cases - Component & Hook Patterns: Composition, compound components, render props, and custom hooks for toggles, debouncing, and referentially stable async data fetching. - State & Performance: Context + Reducer state management, memoization with useMemo/useCallback/React.memo, code splitting with lazy/Suspense, and list virtualization via @tanstack/react-virtual. - Forms, Errors & Accessibility: Controlled form validation, error boundaries, Framer Motion animations, keyboard navigation, and focus management for modals and dropdowns. - Use Case: When building a searchable market dashboard, apply the debounce hook for search input, the useQuery hook for data fetching, and the virtualized list pattern to render thousands of rows smoothly. ## Quick Start Ask the AI to build a React component using these frontend patterns, for example a debounced search input feeding a virtualized list with an error boundary.

Frequently Asked Questions about frontend-patterns

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

FAQPage Schema
How do I fetch data in React with a custom hook?▼

Use a useQuery-style hook that stores the fetcher in a ref and exposes a stable refetch callback. This prevents infinite fetch loops caused by inline functions creating new references on every render, and supports onSuccess, onError, and enabled options.

How to optimize React performance for long lists?▼

Use list virtualization with @tanstack/react-virtual to render only visible rows instead of the full dataset. Combine it with React.memo on row components and useMemo for derived data like sorted arrays to minimize re-renders.

When should I use Context with useReducer instead of useState?▼

Use Context plus useReducer when multiple components share state with several distinct update actions, such as a markets list with selection and loading flags. It centralizes update logic in a reducer and avoids prop drilling through deep trees.

Why does my React useEffect fetch run in an infinite loop?▼

The loop happens when the effect depends on an inline function or object that gets a new reference every render. Store the fetcher and options in refs updated in a separate effect, and keep the refetch callback referentially stable with useCallback.

How do I make a React modal accessible?▼

Add role="dialog" and aria-modal="true", move focus into the modal on open, restore focus to the previously focused element on close, and handle the Escape key to dismiss. The pattern uses refs to track and restore focus correctly.