AGENT SKILL

react-component-pro

Build reusable, accessible, performant React components with hooks, composition patterns, and modern best practices. Use when building React UIs, creating component libraries, or optimizing React performance.

License 许可
CC0-1.0
最近更新
2026-05-06
Stars
★ 14
Forks
2

01 前言 Front Matter

name
react-component-pro
license
CC0-1.0
metadata
{ "tools": "cursor, windsurf, copilot, claude-code", "author": "skillsdirectory", "version": "1.0", "category": "web-development" }
description
Build reusable, accessible, performant React components with hooks, composition patterns, and modern best practices. Use when building React UIs, creating component libraries, or optimizing React performance.
compatibility
Works with Cursor, Windsurf, GitHub Copilot, Claude Code, and any AI coding assistant

03 SKILL.md 正文

React Component Pro

You build production-grade React components that are reusable, accessible, and performant.

Component Principles

  1. Composition over inheritance — Build with small, composable pieces
  2. Single responsibility — One component, one purpose
  3. Props down, events up — Data flows down, actions flow up
  4. Controlled > Uncontrolled — Parent controls state when possible
  5. Accessibility first — ARIA attributes, keyboard navigation, semantic HTML

Component Patterns

Compound Components

<Select value={value} onChange={onChange}>
  <Select.Trigger>Choose option</Select.Trigger>
  <Select.Content>
    <Select.Item value="a">Option A</Select.Item>
    <Select.Item value="b">Option B</Select.Item>
  </Select.Content>
</Select>

Custom Hooks

function useDebounce<T>(value: T, delay: number): T {
  const [debouncedValue, setDebouncedValue] = useState(value)
  
  useEffect(() => {
    const timer = setTimeout(() => setDebouncedValue(value), delay)
    return () => clearTimeout(timer)
  }, [value, delay])
  
  return debouncedValue
}

Render Props / Children as Function

<DataFetcher url="/api/users">
  {({ data, loading, error }) => (
    loading ? <Spinner /> : <UserList users={data} />
  )}
</DataFetcher>

Performance Optimization

Problem Solution
Unnecessary re-renders React.memo, useMemo, useCallback
Heavy computations useMemo with proper deps
Large lists Virtualization (react-window)
Code splitting React.lazy + Suspense
State updates causing full re-render Local state, context splitting

TypeScript Patterns for Components

// Props with children
interface CardProps {
  title: string
  variant?: 'default' | 'outlined' | 'elevated'
  children: React.ReactNode
}

// Forwarded ref
const Input = React.forwardRef<HTMLInputElement, InputProps>(
  ({ label, ...props }, ref) => (
    <div>
      <label>{label}</label>
      <input ref={ref} {...props} />
    </div>
  )
)

// Generic component
interface ListProps<T> {
  items: T[]
  renderItem: (item: T) => React.ReactNode
}

Accessibility Checklist

  • [ ] Semantic HTML (button not div onClick)
  • [ ] ARIA labels for interactive elements
  • [ ] Keyboard navigation (Tab, Enter, Escape)
  • [ ] Focus management (modals, dropdowns)
  • [ ] Color contrast ≥ 4.5:1
  • [ ] Screen reader tested

04 同仓库更多 Skills

luokai0
luokai0/ai-agent-skills-by-luo-kai

write-contracts

Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.

★ 14
luokai0
luokai0/ai-agent-skills-by-luo-kai

web-search

通用网络搜索技能,支持多引擎搜索(百度、必应、DuckDuckGo),无需API密钥即可获取实时信息

★ 14
luokai0
luokai0/ai-agent-skills-by-luo-kai

solo-build

Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says "build it", "start building", "execute plan", "implement tasks", "ship it", or references a track ID. Do NOT use for planning (use /plan) or scaffolding (use /scaffold).

★ 14
luokai0
luokai0/ai-agent-skills-by-luo-kai

react-email

Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.

★ 14
luokai0
luokai0/ai-agent-skills-by-luo-kai

APITester Agent-Driven API Testing

Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.

★ 14
luokai0
luokai0/ai-agent-skills-by-luo-kai

hubspot-implementation-plan

Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running /hubspot-audit.

★ 14