frontend-patterns

Implements React and Next.js patterns for components, state, data fetching, and performance.

5|Updated Jul 8, 2019
One-click install
npx skills add https://github.com/rinchsan/dotfiles --skill frontend-patterns-rinchsan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-patterns
Source: https://github.com/rinchsan/dotfiles/tree/main/.claude/skills/frontend-patterns
Command: npx skills add https://github.com/rinchsan/dotfiles --skill frontend-patterns-rinchsan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Frontend developers often reinvent component structures, state management, and data fetching logic, leading to inconsistent, hard-to-maintain React codebases. This Skill provides proven patterns for common frontend challenges so you can write consistent, performant UI code without trial and error. ## Core Features & Use Cases - Component Patterns: Composition, compound components, and render props for building flexible, reusable React components. - State & Data Fetching: Context + Reducer patterns, custom hooks, and guidance on React Query/SWR for async data. - Performance & Accessibility: Code splitting, list virtualization, memoization guidance, keyboard navigation, and focus management. - Use Case: When building a dashboard with a long scrollable list of items, apply the virtualization pattern with @tanstack/react-virtual and lazy-load heavy chart components to keep the UI responsive. ## Quick Start Ask the AI to build a React component using these frontend patterns, such as a virtualized list or a form validated with React Hook Form and Zod.

Frequently Asked Questions about frontend-patterns

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

FAQPage Schema
How do I manage state in React with Context and useReducer?

Combine React Context with useReducer by defining a state interface, a union of action types, and a reducer function, then expose state and dispatch through a Provider. Create a custom hook like useCart that throws an error when used outside the Provider to catch misuse early.

React Query vs SWR for data fetching, which should I use?

React Query offers caching, background refetching, pagination, and mutation support, making it suited for complex data flows. SWR is a lighter option implementing the stale-while-revalidate pattern. Both are preferred over hand-rolled useEffect fetching hooks.

How do I validate React forms with Zod and React Hook Form?

Define a Zod schema describing your fields, then pass it to useForm via zodResolver from @hookform/resolvers. Register inputs with the register function and display validation messages from formState.errors next to each field.

When should I use React.memo and useMemo for performance?

Use memoization sparingly and only after profiling shows a real performance issue. Premature memoization adds complexity and memory overhead without measurable benefit, so measure first with React DevTools before applying React.memo, useMemo, or useCallback.

How do I render large lists in React without performance issues?

Use list virtualization with @tanstack/react-virtual, which renders only visible rows plus a small overscan buffer. Configure an estimated row size and a scrollable parent container, then position rows absolutely based on the virtualizer's computed offsets.

How do I make a React modal accessible with keyboard navigation?

Add role="dialog" and aria-modal="true", trap focus inside the modal, and close on the Escape key. Save the previously focused element on open and restore focus to it when the modal closes so keyboard users keep their place.