<< All versions

Skill v1.0.1

currentAutomated scan100/100
leahycc/claude-skills/react-performance

+11 new

──Details
PublishedNovember 15, 2026 at 08:45 PM
Content Hashsha256:d4c8080555149f9f...
Git SHA1965880fc263
Bump Typepatch
Compare with v1.0.0
──Files
Files (1 file, 8.7 KB)
SKILL.md8.7 KBactive
SKILL.md · 126 lines · 8.7 KB

name: react-performance description: Use when optimizing React component rendering, fixing Core Web Vitals (LCP, INP, CLS), reducing bundle size, diagnosing re-renders, a store update under a large tree, code splitting, memoization decisions, Server Component patterns, or profiling React apps. Covers React 19, React Compiler, useTransition, useDeferredValue, useEffectEvent, Activity, Suspense, hydration mismatches, and Next.js optimization. metadata: version: "1.0.1"


React Performance

Comprehensive React performance guidance covering measurement, rendering optimization, bundle size, Core Web Vitals, and Server Component patterns. Verified against React docs and Web Vitals specifications.

First principle: Measure before you optimize. This skill teaches you to find problems before fixing them.

Contents

  • Architecture Overview
  • Quick Reference
  • Decision Matrix: Which Optimization?
  • Choose a proportional fix
  • Anti-Patterns Checklist

Architecture Overview

[Diagnose]
├── React DevTools Profiler (component render times)
├── Chrome Performance Panel (main thread activity)
├── web-vitals library (LCP, INP, CLS in production)
└── Bundle analyzer (what's in the bundle)
↓
[Identify Root Cause]
├── Unnecessary re-renders? → Memoization / state colocation
├── Slow initial load? → Code splitting / Server Components
├── Janky interactions? → useTransition / useDeferredValue
├── Layout shifts? → Image/font optimization
└── Large bundle? → Dynamic imports / tree shaking
↓
[Fix — Least Invasive First]
├── 1. Restructure components (children pattern, local state)
├── 2. Consider incremental Compiler adoption if supported and justified
├── 3. Use concurrent features (transitions, deferred values)
├── 4. Move work to Server Components
├── 5. Code split heavy dependencies
└── 6. Manual memo/useMemo/useCallback (last resort)

Before prescribing an API, inspect the app's installed React/Next versions, bundler and Compiler configuration. Preserve the project's supported setup; an optimization task is not automatic authorization to enable a compiler or change frameworks. Source checks are scoped in SOURCES.md.

Quick Reference

Need to...See
Measure performance before optimizingProfiling and Measurement
Fix unnecessary re-rendersRendering Optimization
Reduce JavaScript bundle sizeBundle Optimization
Fix LCP, INP, or CLS scoresCore Web Vitals
Decide Server vs Client ComponentsServer Components
Handle large lists and data setsData and Lists
Optimize images, fonts, and mediaAssets
Decide when React Compiler handles itReact Compiler

Decision Matrix: Which Optimization?

"My page loads slowly"

SymptomLikely CauseFixResource
LCP > 2.5s, large imageUnoptimized hero imageMeasure image discovery/size; choose version-supported loading hintsassets
LCP > 2.5s, text contentRender-blocking JSServer Components, code splitserver-components, bundle
LCP > 2.5s, font flashFont loading delaynext/fontassets
TTFB > 800msSlow data fetchingParallel fetches, streamingserver-components
Large client JS bundleToo much client codeMeasure with next analyze, then split or tree-shakebundle

"My page feels janky/unresponsive"

SymptomLikely CauseFixResource
INP > 200ms on typingHeavy re-renders on inputuseTransition, state colocationrendering
INP > 200ms on clickLong task in the handlerscheduler.yield(), or a workerweb-vitals
INP > 200ms on navigationRoute transition re-rendersuseTransition for navigationrendering
Scrolling stutterLarge list renderingVirtualizationdata-and-lists
Input lagContext re-rendering entire treeSplit context, selector patternrendering
Input loses focus, state resets or an animation restarts on each renderComponent declared inside another component, so React remounts itDeclare it at module top level, pass propsrendering
Effect tears down and re-subscribes on every renderObject, function or read-only value in its dependenciesDepend on primitives or a derived boolean; useEffectEvent for values only read when it firesrendering
Switching tabs loses state or remounts slowlyHidden panel is unmounted<Activity mode="hidden">rendering
Slow first interaction after load, hydration error in consoleServer HTML and first client render differMake them match; client-only parts after hydrationserver-components

"Layout is jumping around"

SymptomLikely CauseFixResource
CLS > 0.1, imagesMissing width/heightnext/image or explicit dimensionsassets, web-vitals
CLS > 0.1, fontsFont swapnext/fontassets
CLS > 0.1, dynamic contentContent inserted after loadReserve space, Suspense fallbackweb-vitals
CLS > 0.1, animationsLayout-triggering CSSUse transform instead of top/leftweb-vitals

"Should I use memo/useMemo/useCallback?"

Inspect whether the affected component is actually compiled. Prefer measuring and fixing state placement or repeated work first. Existing memo/useMemo/useCallback can remain; do not remove them in bulk when enabling Compiler. If the compiler covers new code, manual memoization is often unnecessary, but it can still be useful for a measured case or an external identity contract. A stable callback can matter to an Effect or subscription even when a child is not wrapped in memo.

Choose a proportional fix

Keep code correct, identify the measured bottleneck, and choose the smallest effective change: component structure, memoization, deferred rendering, bundle splitting or server work where the framework supports it. Compiler adoption is a separate, incremental project choice with behavior/performance checks, not an official universal ordering of optimizations. Transitions schedule rendering; they do not split an expensive synchronous function into yielding work.

Anti-Patterns Checklist

When reviewing code, watch for these performance killers:

  • [ ] Effect chains — useEffect that sets state triggering another useEffect (derive during render instead)
  • [ ] Inline object/function props to memo()-wrapped children (defeats memoization)
  • [ ] State too high — input state at page level re-rendering entire tree
  • [ ] `useEffect` for derived state — setFiltered(items.filter(...)) in effect (use useMemo or calculate during render)
  • [ ] Missing `key` prop — or using array index as key for dynamic lists
  • [ ] Context monolith — one Provider with user + theme + cart + notifications
  • [ ] Client Component boundary too high — 'use client' at layout/page level instead of leaf components
  • [ ] Heavy imports in client bundle — syntax highlighters, markdown parsers, date libraries not code-split
  • [ ] Images without dimensions — causes CLS
  • [ ] `onPaste={e => e.preventDefault()}` on password fields — blocks password managers (also an a11y violation)
  • [ ] Manual memo/useMemo/useCallback without measuring first — adds complexity for no proven benefit
  • [ ] Per-asset state or store hook under thousands of siblings. The cost is the walk from the root. Subscribe in an effect and write the DOM. See rendering.md.
  • [ ] `new ExpensiveThing()` in `useRef` initializer — runs every render (use lazy init pattern)
  • [ ] `useState(expensive())`. The call runs on every render. Pass () => expensive().
  • [ ] A component declared inside another component. It remounts on every parent render. Declare it at module level.
  • [ ] App-wide setup in a mount Effect. It runs twice in development. Use a module-level flag or module top-level code.
  • [ ] State set after `await` inside `startTransition`. It is not a transition. Wrap it in another startTransition.
← v1.0.0All versions