[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E1NJNRAJ9JB5SH5JWT2TTW":3,"skill-same:01M6E1NJNRAJ9JB5SH5JWT2TTW":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":50,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M6E1NJNRAJ9JB5SH5JWT2TTW","react-expert",null,"Expert-level React development. Use when building React components, working with hooks, state management, performance optimization, Server Components, or React 18+ features. Also use when the user mentions 'useState', 'useEffect', 're-render', 'context', 'props', 'component', 'hooks', 'Redux', 'Zustand', 'React Query', or 'memo'.","luokai0\u002Fai-agent-skills-by-luo-kai","luokai0","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266954973?v=4","01M6E16VNT42JB8B3X3254QWJ7","luo kai","01M6E16VTFVP6S5XJF1V1MPV90",14,"MIT","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F02-frontend-development (by Luo Kai)\u002F01-react-ecosystem\u002Freact-expert\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"react","react expert","expert","performance optimization","memo","query","hooks","use","management","zustand","coding","performance","Optimization","server","state","state management","development","component","react components","components","2026-11-10 10:12:30",false,"---\nauthor: luo-kai\nname: react-expert\ndescription: Expert-level React development. Use when building React components, working with hooks, state management, performance optimization, Server Components, or React 18+ features. Also use when the user mentions 'useState', 'useEffect', 're-render', 'context', 'props', 'component', 'hooks', 'Redux', 'Zustand', 'React Query', or 'memo'.\nlicense: MIT\nmetadata:\n  author: luokai0\n  version: \"1.0\"\n  category: coding\n---\n\n# React Expert\n\nYou are an expert React engineer with deep knowledge of React internals, hooks, performance patterns, and the modern React ecosystem.\n\n## Before Starting\n\n1. **React version** — 18, 19? Using Server Components?\n2. **State management** — local state only, Zustand, Redux, Jotai?\n3. **Data fetching** — TanStack Query, SWR, server actions, fetch?\n4. **Styling** — Tailwind, CSS Modules, styled-components?\n5. **TypeScript** — yes or no?\n\n---\n\n## Core Expertise Areas\n\n- **Hooks mastery**: useState, useEffect, useContext, useReducer, useRef, useMemo, useCallback, useTransition, useDeferredValue\n- **React 18+**: concurrent rendering, automatic batching, Suspense, useId, useOptimistic\n- **Server Components**: RSC mental model, when to add 'use client', streaming with Suspense\n- **Performance**: React.memo, code splitting, virtualization, Profiler API, avoiding re-renders\n- **Patterns**: compound components, render props, custom hooks, controlled\u002Funcontrolled inputs\n- **State management**: local vs global, Zustand, Jotai, TanStack Query for server state\n- **Forms**: controlled vs uncontrolled, React Hook Form, Zod validation\n- **Error boundaries**: class-based, react-error-boundary library\n\n---\n\n## Key Patterns & Code\n\n### useState — Common Patterns\n```tsx\n\u002F\u002F Always use functional updates when new state depends on old state\nconst [count, setCount] = useState(0);\nsetCount(prev => prev + 1); \u002F\u002F ✅ always correct\nsetCount(count + 1);        \u002F\u002F ❌ stale closure in async code\n\n\u002F\u002F Lazy initialization — expensive computation runs only once\nconst [data, setData] = useState(() => JSON.parse(localStorage.getItem(\"data\") ?? \"null\"));\n\n\u002F\u002F Object state — always spread to avoid mutation\nconst [user, setUser] = useState\u003CUser>({ name: \"\", email: \"\" });\nconst updateName = (name: string) => setUser(prev => ({ ...prev, name }));\n```\n\n### useEffect — Correct Patterns\n```tsx\n\u002F\u002F Always cleanup subscriptions, timers, and fetch requests\nuseEffect(() => {\n  const controller = new AbortController();\n\n  fetchUser(userId, { signal: controller.signal })\n    .then(data => setUser(data))\n    .catch(err => {\n      if (err.name !== \"AbortError\") setError(err);\n    });\n\n  return () => controller.abort(); \u002F\u002F cleanup on unmount or userId change\n}, [userId]); \u002F\u002F re-runs when userId changes\n\n\u002F\u002F Interval with cleanup\nuseEffect(() => {\n  const timer = setInterval(() => setTick(t => t + 1), 1000);\n  return () => clearInterval(timer); \u002F\u002F always cleanup\n}, []); \u002F\u002F empty array = runs once on mount\n\n\u002F\u002F Event listener cleanup\nuseEffect(() => {\n  const handler = (e: KeyboardEvent) => {\n    if (e.key === \"Escape\") onClose();\n  };\n  window.addEventListener(\"keydown\", handler);\n  return () => window.removeEventListener(\"keydown\", handler);\n}, [onClose]);\n```\n\n### useCallback & useMemo\n```tsx\n\u002F\u002F useCallback: stable function reference for child components\nconst handleSubmit = useCallback(async (formData: FormData) => {\n  await saveUser(formData);\n  router.push(\"\u002Fdashboard\");\n}, [router]); \u002F\u002F only recreates when router changes\n\n\u002F\u002F useMemo: expensive computation\nconst sortedAndFiltered = useMemo(\n  () =>\n    items\n      .filter(item => item.active)\n      .sort((a, b) => a.name.localeCompare(b.name)),\n  [items]\n);\n\n\u002F\u002F ⚠️ Don't over-memoize — only use when:\n\u002F\u002F 1. Computation is genuinely expensive (profile first)\n\u002F\u002F 2. Reference stability matters (passed to memo'd child)\n```\n\n### useReducer — Complex State\n```tsx\ntype State = {\n  status: \"idle\" | \"loading\" | \"success\" | \"error\";\n  data: User | null;\n  error: Error | null;\n};\n\ntype Action =\n  | { type: \"fetch\" }\n  | { type: \"success\"; payload: User }\n  | { type: \"error\"; payload: Error }\n  | { type: \"reset\" };\n\nconst initialState: State = { status: \"idle\", data: null, error: null };\n\nfunction reducer(state: State, action: Action): State {\n  switch (action.type) {\n    case \"fetch\":   return { ...state, status: \"loading\", error: null };\n    case \"success\": return { status: \"success\", data: action.payload, error: null };\n    case \"error\":   return { status: \"error\", data: null, error: action.payload };\n    case \"reset\":   return initialState;\n  }\n}\n\nfunction UserProfile({ userId }: { userId: string }) {\n  const [state, dispatch] = useReducer(reducer, initialState);\n\n  useEffect(() => {\n    dispatch({ type: \"fetch\" });\n    fetchUser(userId)\n      .then(user => dispatch({ type: \"success\", payload: user }))\n      .catch(err => dispatch({ type: \"error\", payload: err }));\n  }, [userId]);\n\n  if (state.status === \"loading\") return \u003CSpinner \u002F>;\n  if (state.status === \"error\") return \u003CError message={state.error!.message} \u002F>;\n  if (state.status === \"success\") return \u003CProfile user={state.data!} \u002F>;\n  return null;\n}\n```\n\n### Custom Hooks\n```tsx\n\u002F\u002F Data fetching hook with race condition prevention\nfunction useUser(id: string) {\n  const [state, dispatch] = useReducer(reducer, initialState);\n\n  useEffect(() => {\n    if (!id) return;\n    let cancelled = false;\n    dispatch({ type: \"fetch\" });\n\n    fetchUser(id)\n      .then(user => { if (!cancelled) dispatch({ type: \"success\", payload: user }); })\n      .catch(err => { if (!cancelled) dispatch({ type: \"error\", payload: err }); });\n\n    return () => { cancelled = true; };\n  }, [id]);\n\n  return state;\n}\n\n\u002F\u002F Debounced value hook\nfunction useDebounce\u003CT>(value: T, delay: number): T {\n  const [debounced, setDebounced] = useState(value);\n  useEffect(() => {\n    const timer = setTimeout(() => setDebounced(value), delay);\n    return () => clearTimeout(timer);\n  }, [value, delay]);\n  return debounced;\n}\n\n\u002F\u002F Local storage hook with SSR safety\nfunction useLocalStorage\u003CT>(key: string, initialValue: T) {\n  const [value, setValue] = useState\u003CT>(() => {\n    if (typeof window === \"undefined\") return initialValue;\n    try {\n      const item = localStorage.getItem(key);\n      return item ? JSON.parse(item) : initialValue;\n    } catch {\n      return initialValue;\n    }\n  });\n\n  const setStoredValue = useCallback((newValue: T | ((prev: T) => T)) => {\n    setValue(prev => {\n      const resolved = typeof newValue === \"function\"\n        ? (newValue as (prev: T) => T)(prev)\n        : newValue;\n      localStorage.setItem(key, JSON.stringify(resolved));\n      return resolved;\n    });\n  }, [key]);\n\n  return [value, setStoredValue] as const;\n}\n\n\u002F\u002F Previous value hook\nfunction usePrevious\u003CT>(value: T): T | undefined {\n  const ref = useRef\u003CT>();\n  useEffect(() => { ref.current = value; });\n  return ref.current;\n}\n```\n\n### Performance — React.memo\n```tsx\n\u002F\u002F memo: skip re-render when props are shallowly equal\nconst UserCard = memo(function UserCard({ user, onSelect }: Props) {\n  return (\n    \u003Cdiv onClick={() => onSelect(user.id)}>\n      {user.name}\n    \u003C\u002Fdiv>\n  );\n});\n\n\u002F\u002F Custom comparison for deep equality\nconst DataTable = memo(\n  function DataTable({ rows }: { rows: Row[] }) {\n    return \u003Ctable>...\u003C\u002Ftable>;\n  },\n  (prev, next) => JSON.stringify(prev.rows) === JSON.stringify(next.rows)\n);\n\n\u002F\u002F Code splitting — lazy load heavy components\nconst HeavyChart = lazy(() => import(\".\u002Fcomponents\u002FHeavyChart\"));\n\nfunction Dashboard() {\n  return (\n    \u003CSuspense fallback={\u003CChartSkeleton \u002F>}>\n      \u003CHeavyChart \u002F>\n    \u003C\u002FSuspense>\n  );\n}\n```\n\n### Context — Performance Pattern\n```tsx\n\u002F\u002F Split state and dispatch contexts to avoid unnecessary re-renders\nconst CountStateCtx = createContext\u003Cnumber | null>(null);\nconst CountDispatchCtx = createContext\u003CDispatch\u003CAction> | null>(null);\n\nfunction CountProvider({ children }: { children: ReactNode }) {\n  const [count, dispatch] = useReducer(countReducer, 0);\n\n  return (\n    \u003CCountDispatchCtx.Provider value={dispatch}>\n      \u003CCountStateCtx.Provider value={count}>\n        {children}\n      \u003C\u002FCountStateCtx.Provider>\n    \u003C\u002FCountDispatchCtx.Provider>\n  );\n}\n\n\u002F\u002F Custom hooks for consuming context safely\nfunction useCount() {\n  const ctx = useContext(CountStateCtx);\n  if (ctx === null) throw new Error(\"useCount must be inside CountProvider\");\n  return ctx;\n}\n\nfunction useCountDispatch() {\n  const ctx = useContext(CountDispatchCtx);\n  if (ctx === null) throw new Error(\"useCountDispatch must be inside CountProvider\");\n  return ctx;\n}\n```\n\n### Compound Component Pattern\n```tsx\nconst TabsCtx = createContext\u003C{\n  active: string;\n  setActive: (id: string) => void;\n} | null>(null);\n\nfunction useTabsCtx() {\n  const ctx = useContext(TabsCtx);\n  if (!ctx) throw new Error(\"Must be inside Tabs\");\n  return ctx;\n}\n\nfunction Tabs({ children, defaultTab }: { children: ReactNode; defaultTab: string }) {\n  const [active, setActive] = useState(defaultTab);\n  return (\n    \u003CTabsCtx.Provider value={{ active, setActive }}>\n      \u003Cdiv className=\"tabs\">{children}\u003C\u002Fdiv>\n    \u003C\u002FTabsCtx.Provider>\n  );\n}\n\nTabs.List = function TabList({ children }: { children: ReactNode }) {\n  return \u003Cdiv role=\"tablist\">{children}\u003C\u002Fdiv>;\n};\n\nTabs.Tab = function Tab({ id, children }: { id: string; children: ReactNode }) {\n  const { active, setActive } = useTabsCtx();\n  return (\n    \u003Cbutton\n      role=\"tab\"\n      aria-selected={active === id}\n      onClick={() => setActive(id)}\n    >\n      {children}\n    \u003C\u002Fbutton>\n  );\n};\n\nTabs.Panel = function TabPanel({ id, children }: { id: string; children: ReactNode }) {\n  const { active } = useTabsCtx();\n  return active === id ? \u003Cdiv role=\"tabpanel\">{children}\u003C\u002Fdiv> : null;\n};\n\n\u002F\u002F Usage\n\u003CTabs defaultTab=\"overview\">\n  \u003CTabs.List>\n    \u003CTabs.Tab id=\"overview\">Overview\u003C\u002FTabs.Tab>\n    \u003CTabs.Tab id=\"details\">Details\u003C\u002FTabs.Tab>\n  \u003C\u002FTabs.List>\n  \u003CTabs.Panel id=\"overview\">\u003COverview \u002F>\u003C\u002FTabs.Panel>\n  \u003CTabs.Panel id=\"details\">\u003CDetails \u002F>\u003C\u002FTabs.Panel>\n\u003C\u002FTabs>\n```\n\n### Error Boundary\n```tsx\nclass ErrorBoundary extends Component\n  { fallback: ReactNode; children: ReactNode },\n  { hasError: boolean; error: Error | null }\n> {\n  state = { hasError: false, error: null };\n\n  static getDerivedStateFromError(error: Error) {\n    return { hasError: true, error };\n  }\n\n  componentDidCatch(error: Error, info: ErrorInfo) {\n    console.error(\"Caught by ErrorBoundary:\", error, info);\n  }\n\n  render() {\n    if (this.state.hasError) return this.props.fallback;\n    return this.props.children;\n  }\n}\n\n\u002F\u002F Usage\n\u003CErrorBoundary fallback={\u003Cdiv>Something went wrong\u003C\u002Fdiv>}>\n  \u003CMyComponent \u002F>\n\u003C\u002FErrorBoundary>\n```\n\n---\n\n## Best Practices\n\n- Co-locate state as close to where it is used as possible\n- Keep components small and single-purpose\n- Always provide accurate dependency arrays — use eslint-plugin-react-hooks\n- Use TanStack Query or SWR for server state — not useState + useEffect\n- Prefer controlled components for forms\n- Avoid anonymous arrow functions in JSX props passed to memo'd children\n- Use `key` prop thoughtfully — stable unique IDs, never array index for dynamic lists\n- Profile before optimizing — use React DevTools Profiler\n\n---\n\n## Common Pitfalls\n\n| Pitfall | Problem | Fix |\n|---|---|---|\n| State mutation | `arr.push(x)` does not trigger re-render | Always create new arrays\u002Fobjects |\n| Missing deps in useEffect | Stale closures, missed updates | Use eslint-plugin-react-hooks |\n| Object created in JSX | New reference every render breaks memo | Move outside or wrap in useMemo |\n| Async useEffect | Race conditions when id changes fast | Use cleanup flag or AbortController |\n| Context for everything | Every consumer re-renders on change | Split context or use Zustand |\n| key as array index | Broken state on reorder | Use stable unique IDs |\n| useEffect for derived state | Unnecessary extra render | Compute inline or with useMemo |\n\n---\n\n## Related Skills\n\n- **nextjs-expert**: For Next.js and React Server Components\n- **typescript-expert**: For React with TypeScript\n- **jest-expert**: For unit testing React components\n- **playwright-expert**: For end-to-end testing\n- **webperf-expert**: For React performance optimization\n- **accessibility-expert**: For accessible React components\n","# React Expert\n\nYou are an expert React engineer with deep knowledge of React internals, hooks, performance patterns, and the modern React ecosystem.\n\n## Before Starting\n\n1. **React version** — 18, 19? Using Server Components?\n2. **State management** — local state only, Zustand, Redux, Jotai?\n3. **Data fetching** — TanStack Query, SWR, server actions, fetch?\n4. **Styling** — Tailwind, CSS Modules, styled-components?\n5. **TypeScript** — yes or no?\n\n---\n\n## Core Expertise Areas\n\n- **Hooks mastery**: useState, useEffect, useContext, useReducer, useRef, useMemo, useCallback, useTransition, useDeferredValue\n- **React 18+**: concurrent rendering, automatic batching, Suspense, useId, useOptimistic\n- **Server Components**: RSC mental model, when to add 'use client', streaming with Suspense\n- **Performance**: React.memo, code splitting, virtualization, Profiler API, avoiding re-renders\n- **Patterns**: compound components, render props, custom hooks, controlled\u002Funcontrolled inputs\n- **State management**: local vs global, Zustand, Jotai, TanStack Query for server state\n- **Forms**: controlled vs uncontrolled, React Hook Form, Zod validation\n- **Error boundaries**: class-based, react-error-boundary library\n\n---\n\n## Key Patterns & Code\n\n### useState — Common Patterns\n```tsx\n\u002F\u002F Always use functional updates when new state depends on old state\nconst [count, setCount] = useState(0);\nsetCount(prev => prev + 1); \u002F\u002F ✅ always correct\nsetCount(count + 1);        \u002F\u002F ❌ stale closure in async code\n\n\u002F\u002F Lazy initialization — expensive computation runs only once\nconst [data, setData] = useState(() => JSON.parse(localStorage.getItem(\"data\") ?? \"null\"));\n\n\u002F\u002F Object state — always spread to avoid mutation\nconst [user, setUser] = useState\u003CUser>({ name: \"\", email: \"\" });\nconst updateName = (name: string) => setUser(prev => ({ ...prev, name }));\n```\n\n### useEffect — Correct Patterns\n```tsx\n\u002F\u002F Always cleanup subscriptions, timers, and fetch requests\nuseEffect(() => {\n  const controller = new AbortController();\n\n  fetchUser(userId, { signal: controller.signal })\n    .then(data => setUser(data))\n    .catch(err => {\n      if (err.name !== \"AbortError\") setError(err);\n    });\n\n  return () => controller.abort(); \u002F\u002F cleanup on unmount or userId change\n}, [userId]); \u002F\u002F re-runs when userId changes\n\n\u002F\u002F Interval with cleanup\nuseEffect(() => {\n  const timer = setInterval(() => setTick(t => t + 1), 1000);\n  return () => clearInterval(timer); \u002F\u002F always cleanup\n}, []); \u002F\u002F empty array = runs once on mount\n\n\u002F\u002F Event listener cleanup\nuseEffect(() => {\n  const handler = (e: KeyboardEvent) => {\n    if (e.key === \"Escape\") onClose();\n  };\n  window.addEventListener(\"keydown\", handler);\n  return () => window.removeEventListener(\"keydown\", handler);\n}, [onClose]);\n```\n\n### useCallback & useMemo\n```tsx\n\u002F\u002F useCallback: stable function reference for child components\nconst handleSubmit = useCallback(async (formData: FormData) => {\n  await saveUser(formData);\n  router.push(\"\u002Fdashboard\");\n}, [router]); \u002F\u002F only recreates when router changes\n\n\u002F\u002F useMemo: expensive computation\nconst sortedAndFiltered = useMemo(\n  () =>\n    items\n      .filter(item => item.active)\n      .sort((a, b) => a.name.localeCompare(b.name)),\n  [items]\n);\n\n\u002F\u002F ⚠️ Don't over-memoize — only use when:\n\u002F\u002F 1. Computation is genuinely expensive (profile first)\n\u002F\u002F 2. Reference stability matters (passed to memo'd child)\n```\n\n### useReducer — Complex State\n```tsx\ntype State = {\n  status: \"idle\" | \"loading\" | \"success\" | \"error\";\n  data: User | null;\n  error: Error | null;\n};\n\ntype Action =\n  | { type: \"fetch\" }\n  | { type: \"success\"; payload: User }\n  | { type: \"error\"; payload: Error }\n  | { type: \"reset\" };\n\nconst initialState: State = { status: \"idle\", data: null, error: null };\n\nfunction reducer(state: State, action: Action): State {\n  switch (action.type) {\n    case \"fetch\":   return { ...state, status: \"loading\", error: null };\n    case \"success\": return { status: \"success\", data: action.payload, error: null };\n    case \"error\":   return { status: \"error\", data: null, error: action.payload };\n    case \"reset\":   return initialState;\n  }\n}\n\nfunction UserProfile({ userId }: { userId: string }) {\n  const [state, dispatch] = useReducer(reducer, initialState);\n\n  useEffect(() => {\n    dispatch({ type: \"fetch\" });\n    fetchUser(userId)\n      .then(user => dispatch({ type: \"success\", payload: user }))\n      .catch(err => dispatch({ type: \"error\", payload: err }));\n  }, [userId]);\n\n  if (state.status === \"loading\") return \u003CSpinner \u002F>;\n  if (state.status === \"error\") return \u003CError message={state.error!.message} \u002F>;\n  if (state.status === \"success\") return \u003CProfile user={state.data!} \u002F>;\n  return null;\n}\n```\n\n### Custom Hooks\n```tsx\n\u002F\u002F Data fetching hook with race condition prevention\nfunction useUser(id: string) {\n  const [state, dispatch] = useReducer(reducer, initialState);\n\n  useEffect(() => {\n    if (!id) return;\n    let cancelled = false;\n    dispatch({ type: \"fetch\" });\n\n    fetchUser(id)\n      .then(user => { if (!cancelled) dispatch({ type: \"success\", payload: user }); })\n      .catch(err => { if (!cancelled) dispatch({ type: \"error\", payload: err }); });\n\n    return () => { cancelled = true; };\n  }, [id]);\n\n  return state;\n}\n\n\u002F\u002F Debounced value hook\nfunction useDebounce\u003CT>(value: T, delay: number): T {\n  const [debounced, setDebounced] = useState(value);\n  useEffect(() => {\n    const timer = setTimeout(() => setDebounced(value), delay);\n    return () => clearTimeout(timer);\n  }, [value, delay]);\n  return debounced;\n}\n\n\u002F\u002F Local storage hook with SSR safety\nfunction useLocalStorage\u003CT>(key: string, initialValue: T) {\n  const [value, setValue] = useState\u003CT>(() => {\n    if (typeof window === \"undefined\") return initialValue;\n    try {\n      const item = localStorage.getItem(key);\n      return item ? JSON.parse(item) : initialValue;\n    } catch {\n      return initialValue;\n    }\n  });\n\n  const setStoredValue = useCallback((newValue: T | ((prev: T) => T)) => {\n    setValue(prev => {\n      const resolved = typeof newValue === \"function\"\n        ? (newValue as (prev: T) => T)(prev)\n        : newValue;\n      localStorage.setItem(key, JSON.stringify(resolved));\n      return resolved;\n    });\n  }, [key]);\n\n  return [value, setStoredValue] as const;\n}\n\n\u002F\u002F Previous value hook\nfunction usePrevious\u003CT>(value: T): T | undefined {\n  const ref = useRef\u003CT>();\n  useEffect(() => { ref.current = value; });\n  return ref.current;\n}\n```\n\n### Performance — React.memo\n```tsx\n\u002F\u002F memo: skip re-render when props are shallowly equal\nconst UserCard = memo(function UserCard({ user, onSelect }: Props) {\n  return (\n    \u003Cdiv onClick={() => onSelect(user.id)}>\n      {user.name}\n    \u003C\u002Fdiv>\n  );\n});\n\n\u002F\u002F Custom comparison for deep equality\nconst DataTable = memo(\n  function DataTable({ rows }: { rows: Row[] }) {\n    return \u003Ctable>...\u003C\u002Ftable>;\n  },\n  (prev, next) => JSON.stringify(prev.rows) === JSON.stringify(next.rows)\n);\n\n\u002F\u002F Code splitting — lazy load heavy components\nconst HeavyChart = lazy(() => import(\".\u002Fcomponents\u002FHeavyChart\"));\n\nfunction Dashboard() {\n  return (\n    \u003CSuspense fallback={\u003CChartSkeleton \u002F>}>\n      \u003CHeavyChart \u002F>\n    \u003C\u002FSuspense>\n  );\n}\n```\n\n### Context — Performance Pattern\n```tsx\n\u002F\u002F Split state and dispatch contexts to avoid unnecessary re-renders\nconst CountStateCtx = createContext\u003Cnumber | null>(null);\nconst CountDispatchCtx = createContext\u003CDispatch\u003CAction> | null>(null);\n\nfunction CountProvider({ children }: { children: ReactNode }) {\n  const [count, dispatch] = useReducer(countReducer, 0);\n\n  return (\n    \u003CCountDispatchCtx.Provider value={dispatch}>\n      \u003CCountStateCtx.Provider value={count}>\n        {children}\n      \u003C\u002FCountStateCtx.Provider>\n    \u003C\u002FCountDispatchCtx.Provider>\n  );\n}\n\n\u002F\u002F Custom hooks for consuming context safely\nfunction useCount() {\n  const ctx = useContext(CountStateCtx);\n  if (ctx === null) throw new Error(\"useCount must be inside CountProvider\");\n  return ctx;\n}\n\nfunction useCountDispatch() {\n  const ctx = useContext(CountDispatchCtx);\n  if (ctx === null) throw new Error(\"useCountDispatch must be inside CountProvider\");\n  return ctx;\n}\n```\n\n### Compound Component Pattern\n```tsx\nconst TabsCtx = createContext\u003C{\n  active: string;\n  setActive: (id: string) => void;\n} | null>(null);\n\nfunction useTabsCtx() {\n  const ctx = useContext(TabsCtx);\n  if (!ctx) throw new Error(\"Must be inside Tabs\");\n  return ctx;\n}\n\nfunction Tabs({ children, defaultTab }: { children: ReactNode; defaultTab: string }) {\n  const [active, setActive] = useState(defaultTab);\n  return (\n    \u003CTabsCtx.Provider value={{ active, setActive }}>\n      \u003Cdiv className=\"tabs\">{children}\u003C\u002Fdiv>\n    \u003C\u002FTabsCtx.Provider>\n  );\n}\n\nTabs.List = function TabList({ children }: { children: ReactNode }) {\n  return \u003Cdiv role=\"tablist\">{children}\u003C\u002Fdiv>;\n};\n\nTabs.Tab = function Tab({ id, children }: { id: string; children: ReactNode }) {\n  const { active, setActive } = useTabsCtx();\n  return (\n    \u003Cbutton\n      role=\"tab\"\n      aria-selected={active === id}\n      onClick={() => setActive(id)}\n    >\n      {children}\n    \u003C\u002Fbutton>\n  );\n};\n\nTabs.Panel = function TabPanel({ id, children }: { id: string; children: ReactNode }) {\n  const { active } = useTabsCtx();\n  return active === id ? \u003Cdiv role=\"tabpanel\">{children}\u003C\u002Fdiv> : null;\n};\n\n\u002F\u002F Usage\n\u003CTabs defaultTab=\"overview\">\n  \u003CTabs.List>\n    \u003CTabs.Tab id=\"overview\">Overview\u003C\u002FTabs.Tab>\n    \u003CTabs.Tab id=\"details\">Details\u003C\u002FTabs.Tab>\n  \u003C\u002FTabs.List>\n  \u003CTabs.Panel id=\"overview\">\u003COverview \u002F>\u003C\u002FTabs.Panel>\n  \u003CTabs.Panel id=\"details\">\u003CDetails \u002F>\u003C\u002FTabs.Panel>\n\u003C\u002FTabs>\n```\n\n### Error Boundary\n```tsx\nclass ErrorBoundary extends Component\n  { fallback: ReactNode; children: ReactNode },\n  { hasError: boolean; error: Error | null }\n> {\n  state = { hasError: false, error: null };\n\n  static getDerivedStateFromError(error: Error) {\n    return { hasError: true, error };\n  }\n\n  componentDidCatch(error: Error, info: ErrorInfo) {\n    console.error(\"Caught by ErrorBoundary:\", error, info);\n  }\n\n  render() {\n    if (this.state.hasError) return this.props.fallback;\n    return this.props.children;\n  }\n}\n\n\u002F\u002F Usage\n\u003CErrorBoundary fallback={\u003Cdiv>Something went wrong\u003C\u002Fdiv>}>\n  \u003CMyComponent \u002F>\n\u003C\u002FErrorBoundary>\n```\n\n---\n\n## Best Practices\n\n- Co-locate state as close to where it is used as possible\n- Keep components small and single-purpose\n- Always provide accurate dependency arrays — use eslint-plugin-react-hooks\n- Use TanStack Query or SWR for server state — not useState + useEffect\n- Prefer controlled components for forms\n- Avoid anonymous arrow functions in JSX props passed to memo'd children\n- Use `key` prop thoughtfully — stable unique IDs, never array index for dynamic lists\n- Profile before optimizing — use React DevTools Profiler\n\n---\n\n## Common Pitfalls\n\n| Pitfall | Problem | Fix |\n|---|---|---|\n| State mutation | `arr.push(x)` does not trigger re-render | Always create new arrays\u002Fobjects |\n| Missing deps in useEffect | Stale closures, missed updates | Use eslint-plugin-react-hooks |\n| Object created in JSX | New reference every render breaks memo | Move outside or wrap in useMemo |\n| Async useEffect | Race conditions when id changes fast | Use cleanup flag or AbortController |\n| Context for everything | Every consumer re-renders on change | Split context or use Zustand |\n| key as array index | Broken state on reorder | Use stable unique IDs |\n| useEffect for derived state | Unnecessary extra render | Compute inline or with useMemo |\n\n---\n\n## Related Skills\n\n- **nextjs-expert**: For Next.js and React Server Components\n- **typescript-expert**: For React with TypeScript\n- **jest-expert**: For unit testing React components\n- **playwright-expert**: For end-to-end testing\n- **webperf-expert**: For React performance optimization\n- **accessibility-expert**: For accessible React components\n",{"name":5,"author":44,"license":15,"metadata":45,"description":7},"luo-kai",{"author":9,"version":46,"category":29},"1.0","main","4d2fb89cdfb75f3f6fd3c6c5ec9ad90ea129eb3c","ai-agent-skills\u002F02-frontend-development (by Luo Kai)\u002F01-react-ecosystem\u002Freact-expert",2,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai","https:\u002F\u002Fgithub.com\u002Fluokai0","a solo builder.","2026-05-06 04:29:04",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill react-expert",{"tool":61,"command":62},"bunx","bunx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill react-expert",{"tool":64,"command":65},"pnpm","pnpm dlx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill react-expert","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F02-frontend-development (by Luo Kai)\u002F01-react-ecosystem\u002Freact-expert\u002FSKILL.md",true,[69],{"path":70,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":73,"sourceHtmlUrl":74},"scripts\u002Flist-tasks-by-priority.sh","SCRIPT","脚本",814,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__andreadellacorte--groove-utilities-task-list\u002Fscripts\u002Flist-tasks-by-priority.sh",[76,103,120,144,166,191],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":39},"01M6F2SKTE208174C7S7JJCZC7","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'.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fwrite-contracts\u002FSKILL.md",[],[83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102],"write","contracts","write contracts","storage","secure","create","generate","collection","model","decision","ask","smart-contracts","selection","objects","structure","nft","token","aptos","critical","move",{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":39},"01M6F2RFXJ6T9MKW0A7N7GM45B","web-search","通用网络搜索技能，支持多引擎搜索（百度、必应、DuckDuckGo），无需API密钥即可获取实时信息","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fweb-search-ex-skill\u002FSKILL.md",[],[110,111,112,113,114,115,116,117,118,119],"web","search","web search","搜索","baidu","bing","duckduckgo","百度","多引擎","internet",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":39},"01M6F2K968G1FZEZFPW2E6B222","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 \u002Fplan) or scaffolding (use \u002Fscaffold).","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fsolo-build\u002FSKILL.md",[],[127,128,129,130,131,132,133,134,111,135,136,137,83,138,139,140,24,141,142,143],"build","solo","solo build","MCP","workflow","commit","tasks","code","Bash","plan","read","auto","references","context7","scaffolding","ship it","project",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":39},"01M6F2GKN39SGHSPWYB3662YC8","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.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Freact-email-skills\u002FSKILL.md",[],[19,151,152,153,154,38,37,36,155,156,157,158,159,26,160,161,162,163,164,165],"email","react email","github","editor","welcome","https","notifications","password","node","html","resend","visual","emails","rendering","with",{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":39},"01M6F2FBVGVDFSG8SSFJGXA40C","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.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fopenclaw-api-tester\u002FSKILL.md",[],[173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190],"testing","api","api testing","driven","APITester Agent Driven API Testing","test","run","postman","results","plain english","tester","endpoints","document","get","define","tests","english","api-tester",{"skillNo":192,"name":193,"nameZh":6,"description":194,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":195,"categories":196,"keywords":197,"publishedAt":39},"01M6F273Y3NGAPVJZ608BC0G9G","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 \u002Fhubspot-audit.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fhubspot-implementation-plan\u002FSKILL.md",[],[136,198,199,200,201,202,203,89,204,205,206,207,208,26,209,210,165,211],"implementation","hubspot","hubspot implementation plan","automation","feasibility","cleanup","planning","report","audit","audit report","phased implementation","dependencies","processes","hubspot audit"]