frontend-patterns

Implements React and Next.js component, state management, and performance optimization patterns.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill frontend-patterns-erwinv2k-tkg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-patterns
Source: https://github.com/erwinv2k-TKG/AgentesVSC/tree/main/packs/everything-claude-code/docs/zh-TW/skills/frontend-patterns
Command: npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill frontend-patterns-erwinv2k-tkg

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires react, framer-motion, @tanstack/react-virtual.

What problem does it solve? Building maintainable, high-performance React and Next.js interfaces requires consistent patterns for components, state, forms, and animations, which developers often reinvent inconsistently across projects. ## Core Features & Use Cases - Component Patterns: Composition over inheritance, compound components with Context, and render props for reusable UI building blocks. - Custom Hooks & State Management: Ready-to-use hooks like useToggle, useQuery, and useDebounce, plus Context + Reducer architecture for shared state. - Performance & UX: Memoization, code splitting with lazy loading, list virtualization, form validation, error boundaries, Framer Motion animations, and accessibility patterns for keyboard navigation and focus management. - Use Case: When building a dashboard with a long market list, apply the virtualization pattern with @tanstack/react-virtual and memoized cards to keep rendering smooth. ## Quick Start Ask the assistant to apply the frontend-patterns skill to refactor a React component using compound components and memoization.

Frequently Asked Questions about frontend-patterns

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

FAQPage Schema
How do I optimize React component rendering performance?

Use useMemo for expensive computations, useCallback for functions passed to child components, and React.memo for pure components. For long lists, apply virtualization with @tanstack/react-virtual to render only visible items.

How to manage global state in React without Redux?

Combine React Context with useReducer to create a provider holding shared state and a dispatch function. Expose a custom hook like useMarkets that reads the context and throws if used outside the provider.

What is the compound component pattern in React?

Compound components share implicit state through Context, letting parent components like Tabs coordinate children such as TabList and Tab. This gives flexible composition without prop drilling through intermediate layers.

Does React.lazy work with any component?

React.lazy works with default-exported components loaded via dynamic import and must be wrapped in Suspense with a fallback UI. It is best suited for heavy components like charts or 3D backgrounds that are not needed on initial render.

How do I handle keyboard navigation in a React dropdown?

Listen to onKeyDown events and handle ArrowDown, ArrowUp, Enter, and Escape keys to move an active index, select options, and close the menu. Add ARIA attributes like role="combobox" and aria-expanded for screen reader support.

When should I use render props versus custom hooks?

Custom hooks like useQuery are preferred for sharing stateful logic in modern React. Render props remain useful when a component like DataLoader must give the caller full control over rendering loading, error, and data states inline.