react-patterns

Enforces component shape and hook discipline rules for React function components.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-patterns-tierone-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-patterns
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/react-patterns
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill react-patterns-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React codebases drift into inconsistent component shapes, misused hooks, and effect-heavy logic that causes bugs and rerender churn. This Skill gives an AI assistant a fixed rulebook for writing and reviewing React components and hooks so every change follows the same conventions. ## Core Features & Use Cases - Component shape rules: Enforces function components only, one component per file, typed props with interface or type, deliberate controlled vs uncontrolled design, and restrained forwardRef usage. - Hook discipline: Applies rules-of-hooks, exhaustive dependency arrays, mandatory effect cleanup, and criteria for when extracting a custom hook is justified. - Pattern and anti-pattern guidance: Directs use of compound components, providers, and presentational/container splits while flagging anti-patterns like effects deriving state from props, index keys on dynamic lists, and blanket useCallback/useMemo. - Use Case: When reviewing a PR that adds a new form widget, the assistant checks that the component is controlled, props are typed, effects have cleanup, and list keys use stable identifiers. ## Quick Start Review this React component for hook discipline, controlled state, and anti-patterns before I merge it.

Frequently Asked Questions about react-patterns

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

FAQPage Schema
How do I structure React function components correctly?

Use function components only, one per file, with props typed via interface for public APIs or type for composed types. Choose controlled or uncontrolled deliberately, use named exports for shared UI, and reserve default exports for route-level views.

When should I extract a custom React hook?

Extract a custom hook only when two components share the behavior or the hook has a clear domain identity like useEffectiveSession. Single-use hooks that wrap one effect add noise and should be inlined instead.

Should I use useEffect to sync state from props?

No. Deriving state from props inside useEffect is an anti-pattern; compute the value at render with useMemo or use the prop directly. Effects are reserved for synchronizing with external systems like DOM APIs, timers, and subscriptions.

When is forwardRef needed in React components?

Use forwardRef only when a ref is genuinely required, such as focus management, animation, or third-party DOM library integration. For non-DOM refs, passing a ref as an ordinary prop like inputRef is the modern alternative.

Why is using array index as key a problem in React lists?

Index keys break reconciliation when list items reorder, insert, or delete, causing incorrect state retention and rendering bugs. Always use a stable unique identifier from the data as the key for dynamic lists.