frontend-component-patterns
/frontend-component-patterns
ACTIVATE when creating or refactoring React components, splitting large components, extracting hooks, or deciding Container vs Presentation. ACTIVATE for 'component split', 'Container/Presentation', 'extract hook', 'god component', 'prop drilling'. Covers: Container vs Presentation criteria, when to extract custom hooks (3+ related states), when to split markup (150+ lines), when to move logic to domain service, form section props convention, spotlight/opacity pattern. DO NOT use for: projects not using Container/Presentation (ask first), general React hooks API.
- Author
- fabiensalles ↗
- Repository
- claude-marketplace ↗
- Licence
- MIT
- Last repository change
- 12.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 12.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
ACTIVATE when creating or refactoring React components, splitting large components, extracting hooks, or deciding Container vs Presentation. ACTIVATE for 'component split', 'Container/Presentation', 'extract hook', 'god component', 'prop drilling'. Covers: Container vs Presentation criteria, when to extract custom hooks (3+ related states), when to split markup (150+ lines), when to move logic to domain service, form section props convention, spotlight/opacity pattern. DO NOT use for: projects not using Container/Presentation (ask first), general React hooks API.
Triggers from the description
Original author description
ACTIVATE when creating or refactoring React components, splitting large components, extracting hooks, or deciding Container vs Presentation. ACTIVATE for 'component split', 'Container/Presentation', 'extract hook', 'god component', 'prop drilling'. Covers: Container vs Presentation criteria, when to extract custom hooks (3+ related states), when to split markup (150+ lines), when to move logic to domain service, form section props convention, spotlight/opacity pattern. DO NOT use for: projects not using Container/Presentation (ask first), general React hooks API.
How it works
- Patterns
SKILL.md preview
---
name: frontend-component-patterns
description: "ACTIVATE when creating or refactoring React components, splitting large components, extracting hooks, or deciding Container vs Presentation. ACTIVATE for 'component split', 'Container/Presentation', 'extract hook', 'god component', 'prop drilling'. Covers: Container vs Presentation criteria, when to extract custom hooks (3+ related states), when to split markup (150+ lines), when to move logic to domain service, form section props convention, spotlight/opacity pattern. DO NOT use for: projects not using Container/Presentation (ask first), general React hooks API."
---
# Frontend Component Patterns
Apply only on projects that already follow Container/Presentation patterns. If the project does not use these patterns, ask the user before refactoring.
## Patterns
### Container vs Presentation
**Container components:**
- Use hooks and services for data/state management
- Contain minimal JSX (routing, conditional rendering, layout composition)
- Handle side-effects (API calls via hooks, navigation)
- Example: `ReceiptFormIsland` — uses `useReceiptForm()`, renders `DocumentAsForm` or success screen
**Presentation components:**
- Receive ALL data via props (no hooks, no direct service calls)
- Pure rendering: props → JSX
- Emit events via callback props (`onChange`, `onSubmit`, `onFieldFocus`)
- Example: `BailleurSection` — receives `landlordName`, `errors`, emits `onChange`
### Extraction Criteria
#### When to Extract a Custom Hook
Extract when **3 or more related state variables** are managed together:
- `useState` + `useState` + `useState` for related concerns → `useFeatureName()`
- State + effect + handler that always go together → hook
Do NOT extract a hook for:
- A single `useState`
- State that is only used in one place with no logic
#### When to Split Markup
Split a component when:
- JSX exceeds **150 lines**
- Sections have **independent behavior** (different event handlers, different state dependencies)
- A section is **reusable** across pages
Each extracted section should be **30-60 lines** of JSX.
#### When to Move Logic to a Domain Service
Move to `domain/<concern>.service.ts` when:
- `parseFloat()`, arithmetic, or formatting appears inline in JSX
- Conditional logic determines rendering but is based on pure data transformation
- The same calculation appears in multiple places
- Logic can be described without mentioning React, DOM, or UI concepts
### Component Props Conventions
#### Common Props Pattern for Form Sections
```typescript
interface SectionProps {
// Section-specific data
fieldName: string;
// ...
// Error display
errors: Partial<Record<string, string>>;
// Spotlight/focus system
isActive: boolean;
// Event callbacks
onChange: (field: string, value: string | boolean) => void;
onFieldFocus: (field: string) => void;
onFieldBlur: (field: string) => void;
}
```
#### Opacity/Spotlight Pattern
Use a declarative mapping (in domain service) instead of inline prefix matching:
```typescript
// Domain service — pure mapping
const SECTION_FIELDS: Record<SectionKey, string[]> = {
bailleur: ['landlordName', 'landlordEmail'],
// ...
};
function isSectionActive(currentField: string, section: SectionKey): boolean {
if (!currentField) return true;
return SECTION_FIELDS[section].includes(currentField);
}
```
### Anti-patterns to Avoid
- **God component**: 300+ lines mixing data fetching, state management, business logic, and rendering → split into Container + Presentation + Hook + Service
- **Prop drilling through 3+ levels**: if props pass through a component unchanged, consider co-locating the hook closer to where data is used
- **Inline calculations in JSX**: `{(parseFloat(a) + parseFloat(b)).toFixed(2)}` → extract to domain service
- **Conditional rendering spaghetti**: nested ternaries for section visibility → extract to a declarative mapping
Versions
The database has no other skills named frontend-component-patterns.
Database snapshot: 13.11.2026 · package version d50b5539b497 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100react-container-presentation-component
Create a React component using the Container/Presentation pattern in src/components by asking for the component name and type (ui or features), then scaffold files that follow this repository's TypeScript, Storybook, and SCSS conventions. Use when the user explicitly asks for a… - 100react-patterns
React component patterns and architectural best practices. Covers compound components, render props, higher-order components, custom hooks, composition, state machines, and container/presentational patterns. USE WHEN: user mentions "compound components", "render props", "HOC",… - 95component-patterns
Implement React component patterns including composition, custom hooks, render props, HOCs, and compound components. Use when building reusable React components, implementing design patterns, or refactoring component architecture. - 90react-component-hook-guidelines
Use when reviewing, refactoring, or implementing React components and custom Hooks with unclear boundaries or oversized props. - 100frontend-architecture
Frontend component architecture review — dispatch the component-architecture-review agent over the frontend component files to catch reusable components that should be extracted, duplicated UI patterns, prop drilling, component-granularity problems, and inconsistent component… - 90frontend-patterns
Use this skill when the user asks about frontend design patterns, component patterns, Container/Presentational, Compound Components, HOC, Render Props, Hooks patterns, Provider, or State Reducer.