Agent-skills-standard react-component-patterns
Build modern React component architecture with composition patterns. Use when designing reusable React components, applying composition patterns, or structuring component hierarchies. (triggers: **/*.jsx, **/*.tsx, component, props, children, composition, hoc, render-props)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/react/react-component-patterns" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-react-component-patterns && rm -rf "$T"
manifest:
skills/react/react-component-patterns/SKILL.mdsource content
React Component Patterns
Priority: P0 (CRITICAL)
Implementation Guidelines
- Architecture: Use Compound Components (e.g.,
) for complex state sharing within UI unit. Use Higher-Order Components (HOC) for cross-cutting concerns (e.g.,<Select><Select.Option /></Select>
).withAuth - Composition: Prefer Slots or Render Props (
) over deep prop hierarchies. Userender={(data) => ...}
prop for layout-based composition.children - Components: Distinguish between Controlled (state from props) and Uncontrolled (local
state) components. Favor controlled for form validation.useRef - Props: Use Explicit TS interfaces. Avoid Prop Drilling by leveraging Context API or Zustand for global/deeply nested state.
- Boolean Props: Shorthand
vs<Cmp isVisible />
.isVisible={true} - Conditionals: Ternary (
) overCond ? <A/> : <B/>
for rendering consistency (prevents&&
rendering).0 - Function Components: Only hooks. No classes. Small size (<250 lines). One component per file.
- Exports: Named exports only. PascalCase naming.
Anti-Patterns
- No Classes: Use hooks.
- No Prop Drilling: Use Context/Zustand.
- No Nested Definitions: Define components at top level.
- No Index Keys: Use stable IDs.
- No Inline Handlers: Define before return.
References
See references/patterns.md for Composition, Compound Components, and Render Props examples.