[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E1ZPC45P56MVRRXSAK9CZT":3,"skill-same:01M7E1ZPC45P56MVRRXSAK9CZT":45},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7E1ZPC45P56MVRRXSAK9CZT","react-patterns",null,"React 18\u002F19 patterns including hooks discipline, server\u002Fclient component boundaries, Suspense + error boundaries, form actions, data fetching, state management decision trees, and accessibility-first composition. Use when writing or reviewing React components.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002F.kiro\u002Fskills\u002Freact-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: react-patterns\ndescription: React 18\u002F19 patterns including hooks discipline, server\u002Fclient component boundaries, Suspense + error boundaries, form actions, data fetching, state management decision trees, and accessibility-first composition. Use when writing or reviewing React components.\norigin: ECC\n---\n\n# React Patterns\n\nIdiomatic React 18\u002F19 patterns for building robust, accessible, performant component trees.\n\n## When to Activate\n\n- Writing or modifying React function components, custom hooks, or component trees\n- Reviewing JSX\u002FTSX files\n- Designing state shape or component composition\n- Migrating class components or older `forwardRef`\u002F`useEffect`-heavy code\n- Choosing between local state, lifted state, context, and external stores\n- Working with Server Components \u002F Client Components (Next.js App Router, RSC)\n- Implementing forms with React 19 actions or controlled inputs\n- Wiring data fetching with TanStack Query \u002F SWR \u002F RSC\n\n## Core Principles\n\n### 1. Render is a Pure Function of Props and State\n\n```tsx\n\u002F\u002F Good: derive during render\nfunction Cart({ items }: { items: CartItem[] }) {\n  const total = items.reduce((sum, i) => sum + i.price * i.qty, 0);\n  return \u003Cspan>{formatMoney(total)}\u003C\u002Fspan>;\n}\n\n\u002F\u002F Bad: derived state stored separately\nfunction Cart({ items }: { items: CartItem[] }) {\n  const [total, setTotal] = useState(0);\n  useEffect(() => {\n    setTotal(items.reduce((sum, i) => sum + i.price * i.qty, 0));\n  }, [items]);\n  return \u003Cspan>{formatMoney(total)}\u003C\u002Fspan>;\n}\n```\n\nDerived state in `useEffect` adds a render cycle, can desync, and obscures the data flow.\n\n### 2. Side Effects Outside Render\n\nEffects, mutations, network calls, and subscriptions live in event handlers or `useEffect` — never in the render body.\n\n### 3. Composition Over Inheritance\n\nReact has no inheritance model for components. Compose with `children`, render props, or component props.\n\n## Hooks Discipline\n\nSee [rules\u002Freact\u002Fhooks.md](..\u002F..\u002F..\u002Frules\u002Freact\u002Fhooks.md) for the full ruleset. Highlights:\n\n- Top-level only, never conditional\n- Cleanup every subscription, interval, listener\n- Functional updater (`setX(prev => prev + 1)`) when new state depends on old\n- Default position: do not memoize — add `useMemo`\u002F`useCallback` only when a profiler or a dependency chain proves it matters\n- Extract a custom hook only when the same hook sequence appears in 2+ components\n\n## State Location Decision Tree\n\n```\nUsed by one component?\n  -> useState inside it\n\nUsed by parent + a few descendants?\n  -> lift to nearest common ancestor\n\nUsed across distant branches AND low-frequency reads (theme, auth, locale)?\n  -> React Context\n\nHigh-frequency updates shared across the tree?\n  -> external store (Zustand, Jotai, Redux Toolkit)\n\nDerived from a server?\n  -> server-state library (TanStack Query, SWR, RSC fetch)\n```\n\nMost pages do not need context or a global store. Resist abstraction until duplicated lifting becomes painful.\n\n## Server \u002F Client Components (RSC)\n\n```tsx\n\u002F\u002F Server Component - default, async, never ships JS for itself\nexport default async function ProductPage({ params }: { params: { id: string } }) {\n  const product = await db.product.findUnique({ where: { id: params.id } });\n  if (!product) notFound();\n  return \u003CProductView product={product} \u002F>;\n}\n\n\u002F\u002F Client Component - opt in with \"use client\"\n\"use client\";\nexport function AddToCartButton({ productId }: { productId: string }) {\n  const [pending, startTransition] = useTransition();\n  return (\n    \u003Cbutton\n      disabled={pending}\n      onClick={() => startTransition(() => addToCart(productId))}\n    >\n      {pending ? \"Adding...\" : \"Add to cart\"}\n    \u003C\u002Fbutton>\n  );\n}\n```\n\nBoundaries:\n\n- Server -> Client: pass serializable props or `children`\n- Client -> Server: invoke Server Actions via `\u003Cform action={...}>` or imperatively from event handlers\n- Never `import` a Server Component from a Client Component file — compose them via `children` instead\n\n## Suspense + Error Boundaries\n\n```tsx\n\u003CErrorBoundary fallback={\u003CErrorView \u002F>}>\n  \u003CSuspense fallback={\u003CUserSkeleton \u002F>}>\n    \u003CUserDetail id={id} \u002F>\n  \u003C\u002FSuspense>\n\u003C\u002FErrorBoundary>\n```\n\n- Place Suspense boundaries close to the data, not at the route root — progressively reveal content\n- Error Boundary remains a class API; use `react-error-boundary` for a hook-friendly wrapper\n- A boundary catches errors thrown during render, lifecycle, and constructors of its children — NOT in event handlers or async code\n\n## Forms\n\n### React 19 form actions (preferred for new code)\n\n> **React 19+**: This example uses `useActionState`. For React 18, use `useFormState` from `react-dom` instead.\n\n```tsx\n\"use client\";\nimport { useActionState } from \"react\";\n\nconst initial = { error: null as string | null };\n\nasync function updateUserAction(_prev: typeof initial, formData: FormData) {\n  \"use server\";\n  const parsed = UserSchema.safeParse(Object.fromEntries(formData));\n  if (!parsed.success) return { error: \"Invalid input\" };\n  await db.user.update({ where: { id: parsed.data.id }, data: parsed.data });\n  return { error: null };\n}\n\nexport function UserForm() {\n  const [state, formAction, pending] = useActionState(updateUserAction, initial);\n  return (\n    \u003Cform action={formAction}>\n      \u003Cinput name=\"name\" required \u002F>\n      \u003Cbutton type=\"submit\" disabled={pending}>Save\u003C\u002Fbutton>\n      {state.error && \u003Cp role=\"alert\">{state.error}\u003C\u002Fp>}\n    \u003C\u002Fform>\n  );\n}\n```\n\n### Controlled inputs\n\nUse controlled when the value drives other UI, formats on every keystroke, or implements real-time validation.\n\n### Complex forms\n\nFor multi-step forms, dynamic field arrays, or cross-field validation: use a library (React Hook Form, TanStack Form). Roll-your-own state management for forms past trivial complexity is a maintenance trap.\n\n## Data Fetching Decision Matrix\n\n| Need | Tool |\n|---|---|\n| Per-request data in Next.js App Router | RSC `await fetch()` |\n| Client-side cache + mutations + invalidation | TanStack Query |\n| Lightweight client cache + revalidation | SWR |\n| Real-time subscriptions | Server-Sent Events, WebSockets, or the lib's subscription API |\n| One-off fire-and-forget | `fetch()` in an event handler |\n\nAvoid `useEffect` + `fetch` for application data — race conditions, no cache, no retry, no Suspense integration.\n\n## Composition Recipes\n\n### Slot via `children`\n\n```tsx\n\u003CLayout>\n  \u003CHeader \u002F>\n  \u003CMain>{content}\u003C\u002FMain>\n\u003C\u002FLayout>\n```\n\n### Named slots\n\n```tsx\n\u003CPage header={\u003CNav \u002F>} sidebar={\u003CFilters \u002F>}>\n  \u003CResults \u002F>\n\u003C\u002FPage>\n```\n\n### Compound components (shared state via Context)\n\n```tsx\n\u003CTabs defaultValue=\"profile\">\n  \u003CTabs.List>\n    \u003CTabs.Trigger value=\"profile\">Profile\u003C\u002FTabs.Trigger>\n    \u003CTabs.Trigger value=\"settings\">Settings\u003C\u002FTabs.Trigger>\n  \u003C\u002FTabs.List>\n  \u003CTabs.Panel value=\"profile\">\u003CProfile \u002F>\u003C\u002FTabs.Panel>\n  \u003CTabs.Panel value=\"settings\">\u003CSettings \u002F>\u003C\u002FTabs.Panel>\n\u003C\u002FTabs>\n```\n\n### Render prop \u002F function-as-child\n\nUseful when the parent needs to pass parameters to the rendered output:\n\n```tsx\n\u003CDataLoader id={id}>\n  {({ data, isLoading }) => isLoading ? \u003CSpinner \u002F> : \u003CUserCard user={data} \u002F>}\n\u003C\u002FDataLoader>\n```\n\nModern alternative: a hook (`useData(id)`) returning the same shape — usually cleaner.\n\n## Performance\n\n### When `React.memo` Actually Helps\n\nWrap a component in `React.memo` only when:\n\n1. It re-renders frequently\n2. Its props are usually the same between renders\n3. Its render is measurably expensive\n\n`React.memo` adds an equality check on every render. If props differ on most renders, the check is pure overhead.\n\n### Avoiding Render Cascades\n\n- Lift state down rather than up where possible\n- Split context: one context per concern, so a change to `themeContext` does not re-render auth consumers\n- Use `useSyncExternalStore` for external state libraries — required for safe concurrent rendering\n\n### Lists\n\n- Provide stable `key` props (database id, not array index)\n- Virtualize long lists with `@tanstack\u002Freact-virtual` or `react-window` once visible item count exceeds ~50 with non-trivial rows\n\n## Accessibility-First Composition\n\n- Always render semantic HTML (`\u003Cbutton>`, `\u003Ca>`, `\u003Cnav>`, `\u003Cmain>`) before reaching for `role` attributes\n- Every interactive element must be reachable by keyboard\n- Form inputs need labels — `\u003Clabel htmlFor>` or `aria-label` if visually labeled by an icon\n- Manage focus on route changes and modal open\u002Fclose\n- Run `axe` in component tests (see [skills\u002Freact-testing](..\u002Freact-testing\u002FSKILL.md))\n- Cross-link: [skills\u002Fweb\u002Faccessibility\u002FSKILL.md](..\u002F..\u002F..\u002Fskills\u002Fweb\u002Faccessibility\u002FSKILL.md) covers WCAG criteria and pattern libraries\n\n## Routing\n\nThis skill is router-agnostic. The patterns above work with React Router, TanStack Router, Next.js App Router, Remix Router. Router-specific patterns (loaders, actions, nested layouts) follow the router's documentation — those are framework concerns layered on top of React core.\n\n## Out of Scope (Pointer Sections)\n\n- **Next.js specifics**: App Router data loading, Route Handlers, Middleware, Parallel Routes — separate concern, use Next.js docs\n- **React Native**: Platform-specific patterns differ enough to warrant a separate `react-native-patterns` skill (not present yet)\n- **Remix**: Loader\u002Faction conventions overlap with RSC but follow Remix docs\n\n## Related\n\n- Rules: [rules\u002Freact\u002F](..\u002F..\u002F..\u002Frules\u002Freact\u002F) — coding-style, hooks, patterns, security, testing\n- Skills: [react-performance](..\u002F..\u002F..\u002Fawesome_skills\u002Fecc\u002Freact-performance\u002FSKILL.md) for the Vercel-derived performance ruleset, [frontend-patterns](..\u002Ffrontend-patterns\u002FSKILL.md) for cross-framework UI concerns, [accessibility](..\u002F..\u002F..\u002Fskills\u002Fweb\u002Faccessibility\u002FSKILL.md), [angular-developer](..\u002F..\u002F..\u002Fawesome_skills\u002Fecc\u002Fangular-developer\u002FSKILL.md) for framework comparison\n- Agents: `react-reviewer` for code review, `react-build-resolver` for build\u002Fbundler errors\n- Commands: `\u002Freact-review`, `\u002Freact-build`, `\u002Freact-test`\n\n## Examples\n\n### Custom hook for debounced search\n\n```tsx\nfunction useDebounce\u003CT>(value: T, delay = 300): T {\n  const [debounced, setDebounced] = useState(value);\n  useEffect(() => {\n    const id = setTimeout(() => setDebounced(value), delay);\n    return () => clearTimeout(id);\n  }, [value, delay]);\n  return debounced;\n}\n\nfunction SearchBox() {\n  const [query, setQuery] = useState(\"\");\n  const debounced = useDebounce(query, 300);\n  const { data } = useQuery({\n    queryKey: [\"search\", debounced],\n    queryFn: () => searchApi(debounced),\n    enabled: debounced.length > 0,\n  });\n  return (\n    \u003C>\n      \u003Cinput value={query} onChange={(e) => setQuery(e.target.value)} \u002F>\n      \u003CResults items={data ?? []} \u002F>\n    \u003C\u002F>\n  );\n}\n```\n\n### Optimistic UI with React 19 `useOptimistic`\n\n```tsx\n\"use client\";\nimport { useOptimistic } from \"react\";\n\nexport function MessageList({ messages }: { messages: Message[] }) {\n  const [optimistic, addOptimistic] = useOptimistic(\n    messages,\n    (state, newMessage: Message) => [...state, newMessage],\n  );\n\n  async function send(formData: FormData) {\n    const text = String(formData.get(\"text\"));\n    addOptimistic({ id: \"pending\", text, sender: \"me\" });\n    await saveMessage(text);\n  }\n\n  return (\n    \u003C>\n      \u003Cul>{optimistic.map((m) => \u003Cli key={m.id}>{m.text}\u003C\u002Fli>)}\u003C\u002Ful>\n      \u003Cform action={send}>\n        \u003Cinput name=\"text\" \u002F>\n        \u003Cbutton type=\"submit\">Send\u003C\u002Fbutton>\n      \u003C\u002Fform>\n    \u003C\u002F>\n  );\n}\n```\n\n### Splitting context to avoid render cascades\n\n```tsx\n\u002F\u002F Two contexts: one rarely changes, one frequently\nconst ThemeContext = createContext\u003CTheme>(\"light\");\nconst NotificationsContext = createContext\u003CNotification[]>([]);\n\n\u002F\u002F A component that only consumes ThemeContext does NOT re-render when notifications change\n```\n","# React Patterns\n\nIdiomatic React 18\u002F19 patterns for building robust, accessible, performant component trees.\n\n## When to Activate\n\n- Writing or modifying React function components, custom hooks, or component trees\n- Reviewing JSX\u002FTSX files\n- Designing state shape or component composition\n- Migrating class components or older `forwardRef`\u002F`useEffect`-heavy code\n- Choosing between local state, lifted state, context, and external stores\n- Working with Server Components \u002F Client Components (Next.js App Router, RSC)\n- Implementing forms with React 19 actions or controlled inputs\n- Wiring data fetching with TanStack Query \u002F SWR \u002F RSC\n\n## Core Principles\n\n### 1. Render is a Pure Function of Props and State\n\n```tsx\n\u002F\u002F Good: derive during render\nfunction Cart({ items }: { items: CartItem[] }) {\n  const total = items.reduce((sum, i) => sum + i.price * i.qty, 0);\n  return \u003Cspan>{formatMoney(total)}\u003C\u002Fspan>;\n}\n\n\u002F\u002F Bad: derived state stored separately\nfunction Cart({ items }: { items: CartItem[] }) {\n  const [total, setTotal] = useState(0);\n  useEffect(() => {\n    setTotal(items.reduce((sum, i) => sum + i.price * i.qty, 0));\n  }, [items]);\n  return \u003Cspan>{formatMoney(total)}\u003C\u002Fspan>;\n}\n```\n\nDerived state in `useEffect` adds a render cycle, can desync, and obscures the data flow.\n\n### 2. Side Effects Outside Render\n\nEffects, mutations, network calls, and subscriptions live in event handlers or `useEffect` — never in the render body.\n\n### 3. Composition Over Inheritance\n\nReact has no inheritance model for components. Compose with `children`, render props, or component props.\n\n## Hooks Discipline\n\nSee [rules\u002Freact\u002Fhooks.md](..\u002F..\u002F..\u002Frules\u002Freact\u002Fhooks.md) for the full ruleset. Highlights:\n\n- Top-level only, never conditional\n- Cleanup every subscription, interval, listener\n- Functional updater (`setX(prev => prev + 1)`) when new state depends on old\n- Default position: do not memoize — add `useMemo`\u002F`useCallback` only when a profiler or a dependency chain proves it matters\n- Extract a custom hook only when the same hook sequence appears in 2+ components\n\n## State Location Decision Tree\n\n```\nUsed by one component?\n  -> useState inside it\n\nUsed by parent + a few descendants?\n  -> lift to nearest common ancestor\n\nUsed across distant branches AND low-frequency reads (theme, auth, locale)?\n  -> React Context\n\nHigh-frequency updates shared across the tree?\n  -> external store (Zustand, Jotai, Redux Toolkit)\n\nDerived from a server?\n  -> server-state library (TanStack Query, SWR, RSC fetch)\n```\n\nMost pages do not need context or a global store. Resist abstraction until duplicated lifting becomes painful.\n\n## Server \u002F Client Components (RSC)\n\n```tsx\n\u002F\u002F Server Component - default, async, never ships JS for itself\nexport default async function ProductPage({ params }: { params: { id: string } }) {\n  const product = await db.product.findUnique({ where: { id: params.id } });\n  if (!product) notFound();\n  return \u003CProductView product={product} \u002F>;\n}\n\n\u002F\u002F Client Component - opt in with \"use client\"\n\"use client\";\nexport function AddToCartButton({ productId }: { productId: string }) {\n  const [pending, startTransition] = useTransition();\n  return (\n    \u003Cbutton\n      disabled={pending}\n      onClick={() => startTransition(() => addToCart(productId))}\n    >\n      {pending ? \"Adding...\" : \"Add to cart\"}\n    \u003C\u002Fbutton>\n  );\n}\n```\n\nBoundaries:\n\n- Server -> Client: pass serializable props or `children`\n- Client -> Server: invoke Server Actions via `\u003Cform action={...}>` or imperatively from event handlers\n- Never `import` a Server Component from a Client Component file — compose them via `children` instead\n\n## Suspense + Error Boundaries\n\n```tsx\n\u003CErrorBoundary fallback={\u003CErrorView \u002F>}>\n  \u003CSuspense fallback={\u003CUserSkeleton \u002F>}>\n    \u003CUserDetail id={id} \u002F>\n  \u003C\u002FSuspense>\n\u003C\u002FErrorBoundary>\n```\n\n- Place Suspense boundaries close to the data, not at the route root — progressively reveal content\n- Error Boundary remains a class API; use `react-error-boundary` for a hook-friendly wrapper\n- A boundary catches errors thrown during render, lifecycle, and constructors of its children — NOT in event handlers or async code\n\n## Forms\n\n### React 19 form actions (preferred for new code)\n\n> **React 19+**: This example uses `useActionState`. For React 18, use `useFormState` from `react-dom` instead.\n\n```tsx\n\"use client\";\nimport { useActionState } from \"react\";\n\nconst initial = { error: null as string | null };\n\nasync function updateUserAction(_prev: typeof initial, formData: FormData) {\n  \"use server\";\n  const parsed = UserSchema.safeParse(Object.fromEntries(formData));\n  if (!parsed.success) return { error: \"Invalid input\" };\n  await db.user.update({ where: { id: parsed.data.id }, data: parsed.data });\n  return { error: null };\n}\n\nexport function UserForm() {\n  const [state, formAction, pending] = useActionState(updateUserAction, initial);\n  return (\n    \u003Cform action={formAction}>\n      \u003Cinput name=\"name\" required \u002F>\n      \u003Cbutton type=\"submit\" disabled={pending}>Save\u003C\u002Fbutton>\n      {state.error && \u003Cp role=\"alert\">{state.error}\u003C\u002Fp>}\n    \u003C\u002Fform>\n  );\n}\n```\n\n### Controlled inputs\n\nUse controlled when the value drives other UI, formats on every keystroke, or implements real-time validation.\n\n### Complex forms\n\nFor multi-step forms, dynamic field arrays, or cross-field validation: use a library (React Hook Form, TanStack Form). Roll-your-own state management for forms past trivial complexity is a maintenance trap.\n\n## Data Fetching Decision Matrix\n\n| Need | Tool |\n|---|---|\n| Per-request data in Next.js App Router | RSC `await fetch()` |\n| Client-side cache + mutations + invalidation | TanStack Query |\n| Lightweight client cache + revalidation | SWR |\n| Real-time subscriptions | Server-Sent Events, WebSockets, or the lib's subscription API |\n| One-off fire-and-forget | `fetch()` in an event handler |\n\nAvoid `useEffect` + `fetch` for application data — race conditions, no cache, no retry, no Suspense integration.\n\n## Composition Recipes\n\n### Slot via `children`\n\n```tsx\n\u003CLayout>\n  \u003CHeader \u002F>\n  \u003CMain>{content}\u003C\u002FMain>\n\u003C\u002FLayout>\n```\n\n### Named slots\n\n```tsx\n\u003CPage header={\u003CNav \u002F>} sidebar={\u003CFilters \u002F>}>\n  \u003CResults \u002F>\n\u003C\u002FPage>\n```\n\n### Compound components (shared state via Context)\n\n```tsx\n\u003CTabs defaultValue=\"profile\">\n  \u003CTabs.List>\n    \u003CTabs.Trigger value=\"profile\">Profile\u003C\u002FTabs.Trigger>\n    \u003CTabs.Trigger value=\"settings\">Settings\u003C\u002FTabs.Trigger>\n  \u003C\u002FTabs.List>\n  \u003CTabs.Panel value=\"profile\">\u003CProfile \u002F>\u003C\u002FTabs.Panel>\n  \u003CTabs.Panel value=\"settings\">\u003CSettings \u002F>\u003C\u002FTabs.Panel>\n\u003C\u002FTabs>\n```\n\n### Render prop \u002F function-as-child\n\nUseful when the parent needs to pass parameters to the rendered output:\n\n```tsx\n\u003CDataLoader id={id}>\n  {({ data, isLoading }) => isLoading ? \u003CSpinner \u002F> : \u003CUserCard user={data} \u002F>}\n\u003C\u002FDataLoader>\n```\n\nModern alternative: a hook (`useData(id)`) returning the same shape — usually cleaner.\n\n## Performance\n\n### When `React.memo` Actually Helps\n\nWrap a component in `React.memo` only when:\n\n1. It re-renders frequently\n2. Its props are usually the same between renders\n3. Its render is measurably expensive\n\n`React.memo` adds an equality check on every render. If props differ on most renders, the check is pure overhead.\n\n### Avoiding Render Cascades\n\n- Lift state down rather than up where possible\n- Split context: one context per concern, so a change to `themeContext` does not re-render auth consumers\n- Use `useSyncExternalStore` for external state libraries — required for safe concurrent rendering\n\n### Lists\n\n- Provide stable `key` props (database id, not array index)\n- Virtualize long lists with `@tanstack\u002Freact-virtual` or `react-window` once visible item count exceeds ~50 with non-trivial rows\n\n## Accessibility-First Composition\n\n- Always render semantic HTML (`\u003Cbutton>`, `\u003Ca>`, `\u003Cnav>`, `\u003Cmain>`) before reaching for `role` attributes\n- Every interactive element must be reachable by keyboard\n- Form inputs need labels — `\u003Clabel htmlFor>` or `aria-label` if visually labeled by an icon\n- Manage focus on route changes and modal open\u002Fclose\n- Run `axe` in component tests (see [skills\u002Freact-testing](..\u002Freact-testing\u002FSKILL.md))\n- Cross-link: [skills\u002Fweb\u002Faccessibility\u002FSKILL.md](..\u002F..\u002F..\u002Fskills\u002Fweb\u002Faccessibility\u002FSKILL.md) covers WCAG criteria and pattern libraries\n\n## Routing\n\nThis skill is router-agnostic. The patterns above work with React Router, TanStack Router, Next.js App Router, Remix Router. Router-specific patterns (loaders, actions, nested layouts) follow the router's documentation — those are framework concerns layered on top of React core.\n\n## Out of Scope (Pointer Sections)\n\n- **Next.js specifics**: App Router data loading, Route Handlers, Middleware, Parallel Routes — separate concern, use Next.js docs\n- **React Native**: Platform-specific patterns differ enough to warrant a separate `react-native-patterns` skill (not present yet)\n- **Remix**: Loader\u002Faction conventions overlap with RSC but follow Remix docs\n\n## Related\n\n- Rules: [rules\u002Freact\u002F](..\u002F..\u002F..\u002Frules\u002Freact\u002F) — coding-style, hooks, patterns, security, testing\n- Skills: [react-performance](..\u002F..\u002F..\u002Fawesome_skills\u002Fecc\u002Freact-performance\u002FSKILL.md) for the Vercel-derived performance ruleset, [frontend-patterns](..\u002Ffrontend-patterns\u002FSKILL.md) for cross-framework UI concerns, [accessibility](..\u002F..\u002F..\u002Fskills\u002Fweb\u002Faccessibility\u002FSKILL.md), [angular-developer](..\u002F..\u002F..\u002Fawesome_skills\u002Fecc\u002Fangular-developer\u002FSKILL.md) for framework comparison\n- Agents: `react-reviewer` for code review, `react-build-resolver` for build\u002Fbundler errors\n- Commands: `\u002Freact-review`, `\u002Freact-build`, `\u002Freact-test`\n\n## Examples\n\n### Custom hook for debounced search\n\n```tsx\nfunction useDebounce\u003CT>(value: T, delay = 300): T {\n  const [debounced, setDebounced] = useState(value);\n  useEffect(() => {\n    const id = setTimeout(() => setDebounced(value), delay);\n    return () => clearTimeout(id);\n  }, [value, delay]);\n  return debounced;\n}\n\nfunction SearchBox() {\n  const [query, setQuery] = useState(\"\");\n  const debounced = useDebounce(query, 300);\n  const { data } = useQuery({\n    queryKey: [\"search\", debounced],\n    queryFn: () => searchApi(debounced),\n    enabled: debounced.length > 0,\n  });\n  return (\n    \u003C>\n      \u003Cinput value={query} onChange={(e) => setQuery(e.target.value)} \u002F>\n      \u003CResults items={data ?? []} \u002F>\n    \u003C\u002F>\n  );\n}\n```\n\n### Optimistic UI with React 19 `useOptimistic`\n\n```tsx\n\"use client\";\nimport { useOptimistic } from \"react\";\n\nexport function MessageList({ messages }: { messages: Message[] }) {\n  const [optimistic, addOptimistic] = useOptimistic(\n    messages,\n    (state, newMessage: Message) => [...state, newMessage],\n  );\n\n  async function send(formData: FormData) {\n    const text = String(formData.get(\"text\"));\n    addOptimistic({ id: \"pending\", text, sender: \"me\" });\n    await saveMessage(text);\n  }\n\n  return (\n    \u003C>\n      \u003Cul>{optimistic.map((m) => \u003Cli key={m.id}>{m.text}\u003C\u002Fli>)}\u003C\u002Ful>\n      \u003Cform action={send}>\n        \u003Cinput name=\"text\" \u002F>\n        \u003Cbutton type=\"submit\">Send\u003C\u002Fbutton>\n      \u003C\u002Fform>\n    \u003C\u002F>\n  );\n}\n```\n\n### Splitting context to avoid render cascades\n\n```tsx\n\u002F\u002F Two contexts: one rarely changes, one frequently\nconst ThemeContext = createContext\u003CTheme>(\"light\");\nconst NotificationsContext = createContext\u003CNotification[]>([]);\n\n\u002F\u002F A component that only consumes ThemeContext does NOT re-render when notifications change\n```\n",{"name":5,"origin":24,"description":7},"ECC","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea",".kiro\u002Fskills\u002Freact-patterns","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill react-patterns",{"tool":37,"command":38},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill react-patterns",{"tool":40,"command":41},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill react-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002F.kiro\u002Fskills\u002Freact-patterns\u002FSKILL.md",true,[],[46,54,61,68,75,82],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":53},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":53},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":53},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":53},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":53},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":53},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]