1---2name: thapaliyabikendra-ai-artifacts-react-code-review-patterns3description: React Code Review Patterns4---56# React Code Review Patterns78Checklists and patterns for reviewing React/TypeScript frontend code.910## Quick Reference1112| Priority | Category | Key Checks |13|----------|----------|------------|14| 1 | Security | No secrets, XSS prevention, safe innerHTML |15| 2 | Type Safety | No `any`, explicit types, proper generics |16| 3 | React Patterns | Hooks rules, component structure, keys |17| 4 | Performance | Memoization, bundle size, re-renders |18| 5 | Accessibility | ARIA, keyboard nav, semantic HTML |1920## TypeScript Checklist2122| Check | Required Pattern | Anti-Pattern |23|-------|------------------|--------------|24| Type annotations | Explicit types | `any`, implicit any |25| Generics | Proper constraints | `<any>` |26| Null handling | Strict null checks | `!` assertions |27| Type guards | Proper narrowing | Type casting |28| API types | Generated from schema | Manual types |29| Enums | String enums or const objects | Numeric enums |3031## React Components Checklist3233| Check | Required Pattern | Anti-Pattern |34|-------|------------------|--------------|35| Component type | Functional components | Class components |36| Props typing | Interface/type for props | Inline types, `any` |37| Default props | Default parameters | defaultProps |38| Children | Explicit `children` prop | Implicit |39| Fragments | `<>` or `Fragment` | Unnecessary divs |40| Keys | Stable, unique keys | Index as key |4142## Hooks Checklist4344| Check | Required Pattern | Anti-Pattern |45|-------|------------------|--------------|46| Hook rules | Top level only | Conditional hooks |47| Dependencies | Complete deps array | Missing deps, `// eslint-disable` |48| useEffect cleanup | Return cleanup function | Missing cleanup |49| Custom hooks | `use` prefix | Non-hook abstractions |50| useMemo/useCallback | For expensive ops | Premature optimization |5152## State Management Checklist5354| Check | Required Pattern | Anti-Pattern |55|-------|------------------|--------------|56| Server state | React Query | useState for API data |57| Client state | Context or useState | Redux for simple state |58| Form state | React Hook Form | Manual form handling |59| Loading states | `isLoading`, `isError` | Boolean flags |60| Optimistic updates | React Query mutations | Manual state sync |6162## API Integration Checklist6364| Check | Required Pattern | Anti-Pattern |65|-------|------------------|--------------|66| Data fetching | `useQuery` | `useEffect` + `fetch` |67| Mutations | `useMutation` | Direct API calls |68| Error handling | Error boundaries + query errors | Try-catch everywhere |69| Caching | React Query cache | Manual caching |7071## Performance Checklist7273| Check | Required Pattern | Anti-Pattern |74|-------|------------------|--------------|75| Re-renders | Memoized callbacks | Inline functions in JSX |76| Lists | Virtualization for long lists | Render all items |77| Lazy loading | `React.lazy` + Suspense | All code in bundle |78| Images | Lazy loading, proper sizes | Unoptimized images |7980## Accessibility Checklist8182| Check | Required Pattern | Anti-Pattern |83|-------|------------------|--------------|84| Semantic HTML | `<button>`, `<nav>`, `<main>` | `<div onClick>` |85| ARIA labels | `aria-label`, `aria-describedby` | Missing labels |86| Keyboard nav | `tabIndex`, focus management | Mouse-only interactions |87| Color contrast | WCAG AA compliant | Low contrast |88| Form labels | `<label htmlFor>` | Placeholder only |8990## Testing Checklist9192| Check | Required Pattern | Anti-Pattern |93|-------|------------------|--------------|94| Test coverage | Tests for components | No tests |95| Test type | Behavior tests | Implementation tests |96| Queries | `getByRole`, `getByLabelText` | `getByTestId` |97| Async | `waitFor`, `findBy` | Manual timeouts |98| Mocking | MSW for API | Mock fetch directly |99100## General Checklist101102| Check | Required Pattern | Anti-Pattern |103|-------|------------------|--------------|104| Console | No console.log | Debug statements |105| Comments | Explain "why" | Explain "what" |106| File size | <300 lines per component | Monolithic components |107| Imports | Absolute paths | Relative hell `../../../` |108109## Common Anti-Patterns110111| Anti-Pattern | Issue | Correct Pattern |112|--------------|-------|-----------------|113| `any` type | Loses type safety | Explicit types |114| Index as key | Causes re-render bugs | Stable unique ID |115| Inline functions | Re-creates on render | `useCallback` |116| `useEffect` for derived state | Unnecessary effect | Compute in render |117| `// eslint-disable` | Hiding real issues | Fix the issue |118| Direct DOM manipulation | Bypasses React | Refs or state |119| `dangerouslySetInnerHTML` | XSS risk | Sanitize or avoid |120| Missing error boundaries | Crashes whole app | Error boundary wrapper |121122## References123124- [references/examples.md](references/examples.md) - Code examples for patterns125126---127> Converted and distributed by [TomeVault](https://tomevault.io/claim/thapaliyabikendra) — claim your Tome and manage your conversions.128<!-- tomevault:4.0:skill_md:2026-04-11 -->