React Implementation Patterns
Use this skill to build React UI that is predictable, composable, and easy to reason about under change.
When to Use
- Building, refactoring, or debugging React components, hooks, or client-side interaction flows
- Reviewing React code for component design, state management, or rendering correctness
- Implementing forms, interactive widgets, or data-driven UI with React
- Optimizing React rendering performance (memoization, re-render analysis)
When NOT to Use
- Task is about Next.js-specific routing, SSR, or server components — use
react-nextjs (load alongside react)
- Task is about shadcn/ui component styling or Tailwind class hygiene — use
shadcn-tailwind (load alongside react)
- Task is about Vue, Nuxt, or SwiftUI — use the appropriate framework skill
Delivery Workflow
Use the checklist below and track progress:
React progress:
- [ ] Step 1: Discover project conventions, routing, and state boundaries
- [ ] Step 2: Define component API and ownership of state
- [ ] Step 3: Implement rendering and interaction flow
- [ ] Step 4: Control effects, async state, and performance
- [ ] Step 5: Verify accessibility and tests
Component Design
- Prefer small focused components with a stable public API.
- Keep state as close as possible to where it is used, but no closer than clarity allows.
- Lift state only when multiple consumers genuinely need shared ownership.
- Separate presentational pieces from data orchestration when complexity grows.
- Reuse existing design-system and shared primitives before creating new ones.
Component Composition
- Use compound components for complex widgets with shared context (Select, Tabs, Accordion).
- Always use
forwardRef when building components that wrap native HTML elements or Radix primitives — consumers may need ref access for focus management, scrolling, or measurement.
- Prefer controlled components when the parent needs to read or reset state. Default to uncontrolled when internal state is sufficient and the parent does not observe it.
- Keep one component per file. Export sub-components from the same file only for compound patterns.
- Do not create wrapper components that just pass all props through — that adds indirection without value.
// forwardRef pattern — required for any component wrapping a native element
const Input = forwardRef<HTMLInputElement, InputProps>(
({ label, error, ...props }, ref) => (
<div>
<label>{label}</label>
<input ref={ref} aria-invalid={!!error} {...props} />
{error && <span role="alert">{error}</span>}
</div>
)
);
Input.displayName = 'Input';
State and Effects
- Treat derived data as derived data; do not duplicate it in state.
- Use effects only for synchronization with the outside world.
- Avoid effects that merely reshuffle props into state.
- Keep async state explicit: idle, loading, success, empty, error.
- Clean up subscriptions, timers, and in-flight async work where relevant.
Error Boundaries
- Wrap route-level and critical feature sections with error boundaries — one per feature area, not one for the entire app.
- Show meaningful fallback UI, not just "Something went wrong" — include what failed and what the user can do.
- Log error details to monitoring (Sentry, LogRocket) inside the error boundary handler.
- In Next.js App Router: prefer
error.tsx route files over custom Error Boundary components.
- Reset the boundary state when the user navigates or retries — use a
key prop or resetKeys pattern.
Hooks Guidance
- Keep custom hooks cohesive and named after the capability they provide.
- Do not hide critical side effects inside generic utility hooks.
- Respect hook dependency rules instead of muting them casually.
- Memoize only when it improves observable behavior or avoids real cost.
- Prefer straightforward code over defensive over-abstraction.
Forms and Interaction
- Model validation, dirty state, and submission states explicitly.
- Prevent duplicate submits and inconsistent optimistic UI.
- Keep error messages actionable and close to the affected control.
- Preserve keyboard accessibility and logical tab order.
Rendering Performance
- Avoid re-renders caused by unstable props, inline objects, or unnecessary lifted state.
- Use memoization selectively after identifying a real render issue.
- Keep list keys stable and meaningful.
- Do not solve structural state problems with blanket
memo usage.
React Review Checklist
Architecture:
- [ ] Component boundaries are clear
- [ ] State ownership is appropriate
- [ ] Effects are only used for external synchronization
Behavior:
- [ ] Loading, error, and empty states are intentional
- [ ] Forms and interactive flows handle invalid and repeat actions
- [ ] Derived values are not duplicated in state
Quality:
- [ ] Accessibility semantics are present
- [ ] Tests cover critical user behavior
- [ ] Reuse beats one-off component invention
Anti-Patterns to Avoid
| Anti-Pattern |
Instead Do |
| Syncing props to state without a hard reason |
Derive directly from props or lift ownership properly |
| Huge all-purpose component |
Split by responsibility and data flow |
useEffect as default control flow tool |
Prefer direct render logic, handlers, or dedicated data hooks |
Missing dependencies in useEffect / useCallback |
Declare full dependency arrays or refactor to avoid stale closures |
Using list index as key for dynamic collections |
Use stable item identity keys to avoid reorder/delete bugs |
| Creating inline object/array props in hot render paths |
Use stable references (const or memoized values) |
| Using global Context for rapidly changing local state |
Keep fast-changing state local or in dedicated stores |
| Blanket memoization |
Fix unstable boundaries or measure real bottlenecks |
| One-off styles/components that bypass the system |
Extend existing shared UI patterns |
Connected Skills
react-nextjs - use when the task is specifically about Next.js route and rendering behavior
shadcn-tailwind - use when the UI stack relies on shadcn/ui and Tailwind CSS
ui-design-quality - apply visual design quality rules for typography, color, spacing, animation, and micro-interactions
technical-context-discovery - follow project React conventions before editing
frontend-implementation - apply UI, design-system, and accessibility guidance
ui-verification - verify implementation against approved designs when relevant
1---2name: react3description: React implementation and review patterns for component-driven web UI. Use when Codex needs to build, refactor, debug, or review React components, hooks, forms, client-side state, rendering behavior, accessibility, or data-driven interaction flows.4metadata:5 source: https://skillmd.com/skills/jakubmikolajek/react6---78# React Implementation Patterns910Use this skill to build React UI that is predictable, composable, and easy to reason about under change.1112## When to Use1314- Building, refactoring, or debugging React components, hooks, or client-side interaction flows15- Reviewing React code for component design, state management, or rendering correctness16- Implementing forms, interactive widgets, or data-driven UI with React17- Optimizing React rendering performance (memoization, re-render analysis)1819## When NOT to Use2021- Task is about Next.js-specific routing, SSR, or server components — use `react-nextjs` (load alongside `react`)22- Task is about shadcn/ui component styling or Tailwind class hygiene — use `shadcn-tailwind` (load alongside `react`)23- Task is about Vue, Nuxt, or SwiftUI — use the appropriate framework skill2425## Delivery Workflow2627Use the checklist below and track progress:2829```30React progress:31- [ ] Step 1: Discover project conventions, routing, and state boundaries32- [ ] Step 2: Define component API and ownership of state33- [ ] Step 3: Implement rendering and interaction flow34- [ ] Step 4: Control effects, async state, and performance35- [ ] Step 5: Verify accessibility and tests36```3738## Component Design3940- Prefer small focused components with a stable public API.41- Keep state as close as possible to where it is used, but no closer than clarity allows.42- Lift state only when multiple consumers genuinely need shared ownership.43- Separate presentational pieces from data orchestration when complexity grows.44- Reuse existing design-system and shared primitives before creating new ones.4546### Component Composition4748- Use compound components for complex widgets with shared context (Select, Tabs, Accordion).49- Always use `forwardRef` when building components that wrap native HTML elements or Radix primitives — consumers may need ref access for focus management, scrolling, or measurement.50- Prefer controlled components when the parent needs to read or reset state. Default to uncontrolled when internal state is sufficient and the parent does not observe it.51- Keep one component per file. Export sub-components from the same file only for compound patterns.52- Do not create wrapper components that just pass all props through — that adds indirection without value.5354```tsx55// forwardRef pattern — required for any component wrapping a native element56const Input = forwardRef<HTMLInputElement, InputProps>(57 ({ label, error, ...props }, ref) => (58 <div>59 <label>{label}</label>60 <input ref={ref} aria-invalid={!!error} {...props} />61 {error && <span role="alert">{error}</span>}62 </div>63 )64);65Input.displayName = 'Input';66```6768## State and Effects6970- Treat derived data as derived data; do not duplicate it in state.71- Use effects only for synchronization with the outside world.72- Avoid effects that merely reshuffle props into state.73- Keep async state explicit: idle, loading, success, empty, error.74- Clean up subscriptions, timers, and in-flight async work where relevant.7576## Error Boundaries7778- Wrap route-level and critical feature sections with error boundaries — one per feature area, not one for the entire app.79- Show meaningful fallback UI, not just "Something went wrong" — include what failed and what the user can do.80- Log error details to monitoring (Sentry, LogRocket) inside the error boundary handler.81- In Next.js App Router: prefer `error.tsx` route files over custom Error Boundary components.82- Reset the boundary state when the user navigates or retries — use a `key` prop or `resetKeys` pattern.8384## Hooks Guidance8586- Keep custom hooks cohesive and named after the capability they provide.87- Do not hide critical side effects inside generic utility hooks.88- Respect hook dependency rules instead of muting them casually.89- Memoize only when it improves observable behavior or avoids real cost.90- Prefer straightforward code over defensive over-abstraction.9192## Forms and Interaction9394- Model validation, dirty state, and submission states explicitly.95- Prevent duplicate submits and inconsistent optimistic UI.96- Keep error messages actionable and close to the affected control.97- Preserve keyboard accessibility and logical tab order.9899## Rendering Performance100101- Avoid re-renders caused by unstable props, inline objects, or unnecessary lifted state.102- Use memoization selectively after identifying a real render issue.103- Keep list keys stable and meaningful.104- Do not solve structural state problems with blanket `memo` usage.105106## React Review Checklist107108```109Architecture:110- [ ] Component boundaries are clear111- [ ] State ownership is appropriate112- [ ] Effects are only used for external synchronization113114Behavior:115- [ ] Loading, error, and empty states are intentional116- [ ] Forms and interactive flows handle invalid and repeat actions117- [ ] Derived values are not duplicated in state118119Quality:120- [ ] Accessibility semantics are present121- [ ] Tests cover critical user behavior122- [ ] Reuse beats one-off component invention123```124125## Anti-Patterns to Avoid126127| Anti-Pattern | Instead Do |128|---|---|129| Syncing props to state without a hard reason | Derive directly from props or lift ownership properly |130| Huge all-purpose component | Split by responsibility and data flow |131| `useEffect` as default control flow tool | Prefer direct render logic, handlers, or dedicated data hooks |132| Missing dependencies in `useEffect` / `useCallback` | Declare full dependency arrays or refactor to avoid stale closures |133| Using list index as `key` for dynamic collections | Use stable item identity keys to avoid reorder/delete bugs |134| Creating inline object/array props in hot render paths | Use stable references (`const` or memoized values) |135| Using global Context for rapidly changing local state | Keep fast-changing state local or in dedicated stores |136| Blanket memoization | Fix unstable boundaries or measure real bottlenecks |137| One-off styles/components that bypass the system | Extend existing shared UI patterns |138139## Connected Skills140141- `react-nextjs` - use when the task is specifically about Next.js route and rendering behavior142- `shadcn-tailwind` - use when the UI stack relies on shadcn/ui and Tailwind CSS143- `ui-design-quality` - apply visual design quality rules for typography, color, spacing, animation, and micro-interactions144- `technical-context-discovery` - follow project React conventions before editing145- `frontend-implementation` - apply UI, design-system, and accessibility guidance146- `ui-verification` - verify implementation against approved designs when relevant