[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76RZ528FANTKX7Q9XR0CXM7":3,"skill-same:01M76RZ528FANTKX7Q9XR0CXM7":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M76RZ528FANTKX7Q9XR0CXM7","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.","AlexanderNarbaev\u002Fagi","AlexanderNarbaev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F33544956?v=4","01M755ZKB1JJ26ZBNZSDJ4C0TV","01M755ZKBX072HZMHVQBWK7MK7",1,"AGPL-3.0","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Freact-patterns\u002FSKILL.md",[],[],"2026-11-12 13:55:43",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.\nused-by:\n  - \"Code\"\n  - \"General\"\nschemaVersion: \"v0.1\"\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..\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```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\u002Faccessibility\u002FSKILL.md](..\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..\u002Frules\u002Freact\u002F) — coding-style, hooks, patterns, security, testing\n- Skills: [react-performance](..\u002Freact-performance\u002FSKILL.md) for the Vercel-derived performance ruleset, [frontend-patterns](..\u002Ffrontend-patterns\u002FSKILL.md) for cross-framework UI concerns, [accessibility](..\u002Faccessibility\u002FSKILL.md), [angular-developer](..\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..\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```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\u002Faccessibility\u002FSKILL.md](..\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..\u002Frules\u002Freact\u002F) — coding-style, hooks, patterns, security, testing\n- Skills: [react-performance](..\u002Freact-performance\u002FSKILL.md) for the Vercel-derived performance ruleset, [frontend-patterns](..\u002Ffrontend-patterns\u002FSKILL.md) for cross-framework UI concerns, [accessibility](..\u002Faccessibility\u002FSKILL.md), [angular-developer](..\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,"used-by":23,"description":7,"schemaVersion":26},[24,25],"Code","General","v0.1","main","7709dc9e5ebd3bd641124ad2a3f6bb053ac2dab6",".veai\u002Fskills\u002Freact-patterns",0,"https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev","2026-11-15 04:35:36",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add AlexanderNarbaev\u002Fagi --skill react-patterns",{"tool":40,"command":41},"bunx","bunx skills add AlexanderNarbaev\u002Fagi --skill react-patterns",{"tool":43,"command":44},"pnpm","pnpm dlx skills add AlexanderNarbaev\u002Fagi --skill react-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Freact-patterns\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M76RZHYHMGE1WP9JBCMNA801","springboot-patterns","Spring Boot architecture patterns, REST API design, layered services, data access, caching, async processing, and logging. Use for Java Spring Boot backend work.","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Fspringboot-patterns\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M76RZE6JNZH5HV7Q8JM7R0PN","search-first","Research-before-coding workflow. Search for existing tools, libraries, and patterns before writing custom code. Invokes the researcher agent.","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Fsearch-first\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M76RZBV42EMQV77H7GMFY4AJ","scholar-evaluation","Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Fscholar-evaluation\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M76RZ97GC3XAY48H126C30PM","redis-patterns","Redis data structure patterns, caching strategies, distributed locks, rate limiting, pub\u002Fsub, and connection management for production applications.","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Fredis-patterns\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M76RZ1244PZQRQV5HBQ4PVYQ","query-patterns","SQL patterns, relational database design, query optimization, transactions, analytics, and dialect-aware best practices.","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Fquery-patterns\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M76RYX096DW0ARAVQMJ60WXB","python-patterns","Pythonic idioms, PEP 8 standards, type hints, and best practices for building robust, efficient, and maintainable Python applications.","https:\u002F\u002Fgithub.com\u002FAlexanderNarbaev\u002Fagi\u002Fblob\u002Fmain\u002F.veai\u002Fskills\u002Fpython-patterns\u002FSKILL.md",[],[]]