component-architecture

Enforces layered React component architecture and UX patterns for the Layer component library.

10|3|Updated Oct 23, 2023
One-click install
npx skills add https://github.com/Layer-Fi/layer-react --skill component-architecture-layer-fi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: component-architecture
Source: https://github.com/Layer-Fi/layer-react/tree/main/src/components
Command: npx skills add https://github.com/Layer-Fi/layer-react --skill component-architecture-layer-fi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires react, react-aria-components, @tanstack/react-table, react-i18next, classnames, lucide-react, motion.

What problem does it solve? It prevents architectural drift in a large React component library by defining exactly where new components belong, how they handle loading and empty states, and which conventions govern forms, tables, and responsive behavior. ## Core Features & Use Cases - Four-layer architecture: Enforces a one-way dependency rule across ui primitives, blocks, features, and views so domain code never leaks into reusable primitives. - State handling utilities: Replaces hand-rolled isLoading/isError ladders with ConditionalBlock and ConditionalList components whose union prop types force complete state handling at compile time. - Slots and slotProps conventions: Standardizes how consumers inject content and configure internal elements without ad-hoc props. - Use Case: When adding a new mileage tracking UI, the skill directs you to place it in @features/mileage, reuse @blocks table variants, wire loading states through ConditionalList, and expose customization via slots rather than new one-off props. ## Quick Start Ask the assistant to review or scaffold a new React component following the component-architecture layering, state handling, and slots conventions.

Frequently Asked Questions about component-architecture

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

FAQPage Schema
How do I decide where a new React component belongs in a layered architecture?▼

Place domain-agnostic primitives in ui, composed reusable patterns in blocks, domain-specific components that fetch their own data in features, and full pages in views. Dependencies flow one way: views to features to blocks to ui.

How should React components handle loading, error, and empty states?▼

Use ConditionalBlock for a single data object and ConditionalList for arrays instead of hand-rolled ternary ladders. Their union prop types force you to supply Loading or Error nodes whenever you pass isLoading or isError, so TypeScript catches half-handled states.

When should I avoid useEffect for state in React?▼

Avoid effects when a value can be derived during render, computed in an event handler, or reset with a key prop. Reserve useEffect for synchronizing with external systems like subscriptions, timers, or imperative DOM APIs.

What is the difference between slots and slotProps in component APIs?▼

slots inject what to render into named regions, accepting nodes or components keyed by PascalCase names. slotProps configure how internal elements render without exposing them, keyed by the element name such as Title or Popover.

Can ui primitives import feature hooks or schemas?▼

No. Primitives in the ui layer must remain domain-agnostic and cannot import schemas, data-fetching hooks, or feature components. A feature component translates its domain config into whatever the primitive below it accepts.