Help us improve
Share bugs, ideas, or general feedback.
From majestic-react
Guides implementation of modern React patterns: hooks, component composition, state management, performance optimizations, concurrent features. Use for building or refactoring components.
npx claudepluginhub majesticlabs-dev/majestic-marketplace --plugin majestic-reactHow this skill is triggered — by the user, by Claude, or both
Slash command
/majestic-react:react-patternsThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Expert guidance for implementing modern React patterns using hooks, component composition, state management, and concurrent features.
Provides modern React patterns for component design, hooks, composition, state management, performance, error handling, and TypeScript best practices. Useful for production-ready apps.
Provides 10 high-impact React patterns and anti-patterns for state management, performance, hooks, and component design. Use when writing or reviewing React components.
Corrects stale React 18/19 patterns and anti-patterns — hooks discipline, component architecture, state management, and common LLM training data mistakes.
Share bugs, ideas, or general feedback.
Expert guidance for implementing modern React patterns using hooks, component composition, state management, and concurrent features.
| Priority | Description |
|---|---|
| Component Composition | Build complex UIs from simple, reusable pieces |
| Separation of Concerns | Business logic in hooks, presentation in components |
| Explicit over Implicit | Clear data flow and state management |
| Performance | Minimize re-renders, optimize heavy computations |
| Accessibility | Build inclusive, keyboard-navigable interfaces |
| Pattern | Use Case | Example |
|---|---|---|
| Compound Components | Flexible component APIs with shared context | Accordion, Tabs, Menu |
| Render Props | Share logic between components | MouseTracker, Scroll position |
| Higher-Order Components | Wrap components to add functionality | withAuth, withLoading |
See references/examples.md for full code examples.
| Hook | Purpose |
|---|---|
useApi | Data fetching with loading/error states |
useForm | Form state management with validation |
useDebounce | Debounce rapidly changing values |
usePrevious | Access previous value of state/prop |
useLocalStorage | Persist state to localStorage |
See references/examples.md for implementations.
| Type | When to Use | Examples |
|---|---|---|
| useState | Simple UI state | Toggles, form inputs, pagination |
| useReducer | Complex state logic | Multi-step forms, shopping cart |
| Context | Theme, auth, app-wide settings | User session, feature flags |
| URL State | Shareable/bookmarkable state | Filters, search params, tabs |
| Server State | API data (React Query/SWR) | User profiles, product catalogs |
| Global Store | Cross-feature coordination | Zustand/Redux for complex apps |
Context + useReducer Pattern: Best for complex state with multiple actions that need to be shared across components. See references/examples.md.
| Tool | Use When |
|---|---|
useMemo | Expensive calculations (sorting, filtering large arrays) |
useCallback | Functions passed to memoized children or used in deps |
memo | Pure components that re-render often with same props |
| Level | Implementation |
|---|---|
| Route-level | lazy(() => import('./pages/Dashboard')) |
| Component-level | Heavy components like charts, editors |
| Conditional | Features behind feature flags |
Always wrap lazy components in <Suspense> with appropriate fallback.
| Strategy | Scope |
|---|---|
| Error Boundaries | Component tree errors (class components) |
| try/catch | Async operations, event handlers |
| React Query onError | API errors with automatic retry |
Error Boundary Placement: App-level for fatal errors, feature-level for graceful degradation.
| Requirement | Implementation |
|---|---|
| Focus Management | Return focus to trigger on modal close |
| Keyboard Navigation | Support Tab, Enter, Escape in interactive elements |
| ARIA Labels | Icon buttons, form inputs without visible labels |
| Semantic HTML | Use <nav>, <main>, <button> appropriately |
See references/examples.md for accessible modal implementation.