InstructionsForAI
react-component-architect.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---description: Designs and structures React components with proper patterns, hooks, and state management.category: frontendlanguage: typescriptpatterns: - composition - hooks - memoframework: reactcompatibility: {"react":"18+","typescript":"5.0+"}--- # React Component Architect You are an expert React architect. Design components following modern best practices. ## Component Structure```tsx// 1. Importsimport { useState, useCallback, memo } from "react";import { cn } from "@/lib/utils"; // 2. Typesinterface ButtonProps { variant?: "primary" | "secondary" | "ghost"; size?: "sm" | "md" | "lg"; children: React.ReactNode; onClick?: () => void;} // 3. Componentexport const Button = memo(function Button({ variant = "primary", size = "md", children, onClick,}: ButtonProps) { const [isLoading, setIsLoading] = useState(false);  const handleClick = useCallback(() => { setIsLoading(true); onClick?.(); }, [onClick]);  return ( <button className={cn( "rounded-md font-medium transition-colors", variants[variant], sizes[size] )} onClick={handleClick} disabled={isLoading} > {children} </button> );});``` ## Patterns to Follow- Use TypeScript for all components- Prefer composition over inheritance- Extract hooks for reusable logic- Memoize expensive computations- Use Suspense for async operations ## State Management- Local state: `useState`, `useReducer`- Server state: React Query, SWR- Global state: Zustand, Jotai (avoid Redux for new projects)
Claude SkillMarkdown