React frontend

From iliaal/whetstone · View interactive version

React frontend is an AI agent skill from the GitHub repository iliaal/whetstone. React, TypeScript, and Next.js patterns for frontend development. Use when building React components, managing state, fetching data, optimizing performance, or working with Next.js App Router. Covers React 18-19, hooks, Server Components, and type-safe patterns.

How to use this skill

Skill file

React Frontend

Component TypeScript

Effects Decision Tree

Effects are escape hatches — most logic should NOT use effects.

| Need | Solution |

|------|----------|

| Derived value from props/state | Calculate during render (useMemo if expensive) |

| Reset state on prop change | key prop on component |

| Respond to user event | Event handler |

| Notify parent of state change | Call onChange in event handler, or fully controlled component |

| Chain of state updates | Calculate all next state in one event handler |

| Sync with external system | Effect with cleanup |

Effect rules:

State Management

Local UI state       → useState, useReducer
Shared client state  → Zustand (simple) | Redux Toolkit (complex)
Atomic/granular      → Jotai
Server/remote data   → React Query (TanStack Query)
URL state            → nuqs, router search params
Form state           → React Hook Form

Key patterns:

Performance

Critical — eliminate waterfalls:

Critical — bundle size:

Re-render optimization:

React Compiler (React 19): auto-memoizes — write idiomatic React, remove manual useMemo/useCallback/memo. Install babel-plugin-react-compiler, keep components pure.

React 19

Next.js App Router

File conventions: page.tsx (route UI), layout.tsx (shared wrapper), loading.tsx (Suspense), error.tsx (error boundary), not-found.tsx (404), route.ts (API endpoint)

Rendering modes: Server Components (default) | Client ('use client') | Static (build) | Dynamic (request) | Streaming (progressive)

Decision: Server Component unless it needs hooks, event handlers, or browser APIs. Split: server parent + client child.

Routing patterns:

Caching:

Data fetching: Fetch in Server Components where data is used. Use Suspense boundaries for slow queries. React.cache() for per-request dedup. generateStaticParams for static generation. generateMetadata for dynamic SEO.

Discipline

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.