[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7FCK38K1JGNRYPJDH01W2RG":3,"skill-same:01M7FCK38K1JGNRYPJDH01W2RG":49},{"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":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M7FCK38K1JGNRYPJDH01W2RG","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.","siddu1004\u002FSFP","siddu1004","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F260113491?v=4","01M7F8W1SAJAR49097VRTE1TW5","Siddhardh Vanguri","01M7F8W1SYGY7JE15AHAECCT9R",5,"MIT","https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Ffrontend\u002Fskills\u002Freact-patterns\u002FSKILL.md",[],[],"2026-11-16 10:05:34",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.\nmetadata:\n  origin: 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..\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,"metadata":24,"description":7},{"origin":25},"ECC","main","15fa5201935d2b1d172b4e61c2360c908d876d20","plugins\u002Ffrontend\u002Fskills\u002Freact-patterns",0,"https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP","https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fsfp-hive","https:\u002F\u002Fgithub.com\u002Fsiddu1004","I am a student at Amrita Vishwa Vidyapeetham pursuing my BTECH degree in Electronics and Electrical Engineering (2024-2028).","2026-11-09 16:04:40",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add siddu1004\u002FSFP --skill react-patterns",{"tool":41,"command":42},"bunx","bunx skills add siddu1004\u002FSFP --skill react-patterns",{"tool":44,"command":45},"pnpm","pnpm dlx skills add siddu1004\u002FSFP --skill react-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Ffrontend\u002Fskills\u002Freact-patterns\u002FSKILL.md",true,[],[50,57,64,71,78,85],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M7FEEDADZBNBVY19H3XZKCBQ","scientific-schematics","Generates scientific diagram drafts using Nano Banana 2 AI with smart iterative refinement. Uses Gemini 3.7 Flash for quality review. Refines when the review requests improvement, with at most two generations. Specialized in neural network architectures, system diagrams, flowcharts, biological pathways, and complex scientific visualizations.","https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Fscience-hardware\u002Fskills\u002Fscientific-schematics\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7FEE0JS04FE58MST48D0MMC","polyhaven-texture-apply","Apply realistic PBR textures from PolyHaven to any Blender object. Supports metals, wood, concrete, fabric, and more. Trigger when asked to texture an object, apply a material from PolyHaven, make something look like metal\u002Fwood\u002Fmarble, or change object surface.","https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Fscience-hardware\u002Fskills\u002Fpolyhaven-texture-apply\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7FEDJRWV194TY411WVRS84W","polyhaven-studio-setup","Set up a professional product photography studio in Blender using PolyHaven HDRIs and PBR ground materials. Trigger when asked to create a studio setup, add HDRI lighting, set up product photography, or create a showroom scene.","https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Fscience-hardware\u002Fskills\u002Fpolyhaven-studio-setup\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7FED5H2FGS50XGETMGSM0RV","polyhaven-scene-builder","Build complete product scenes using PolyHaven assets — HDRI environment, textured ground\u002Fpedestal, and optional props from the 3D model library. Trigger when asked to build a product scene, create a showcase setup, add a pedestal, or compose a product shot.","https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Fscience-hardware\u002Fskills\u002Fpolyhaven-scene-builder\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7FECSNZ2CJA7Z8TPE5R844R","polyhaven-material-swap","Cycle through multiple PolyHaven materials on a product and render each variant. Great for showing color\u002Ffinish options. Trigger when asked to show material variants, swap textures, create color options, show finish comparisons, or render product in different materials.","https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Fscience-hardware\u002Fskills\u002Fpolyhaven-material-swap\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7FECBPQ6YWH48PYAMS0C5CE","polyhaven-hdri-showcase","Render the same product across multiple HDRI environments and output a comparison grid. Trigger when asked to compare lighting setups, test different environments, show product in multiple settings, or create an HDRI comparison.","https:\u002F\u002Fgithub.com\u002Fsiddu1004\u002FSFP\u002Fblob\u002Fmain\u002Fplugins\u002Fscience-hardware\u002Fskills\u002Fpolyhaven-hdri-showcase\u002FSKILL.md",[],[]]