Skip to main content
skill CX Codex

react-component-performance — Claude Code skill

Identifies React render hotspots, isolates fast-changing state, and eliminates re-render churn. Useful when lists lag or components re-render too often.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Dimillian/Skills --skill react-component-performance -a claude-code
Open on GitHub

What react-component-performance does

The skill enforces a clear debugging workflow for UI slowdowns: reproduce the lag, trace what triggers re-renders, isolate volatile state, and memoize only where it actually helps. It targets state that updates frequently on timers, scrolls, inputs, or animations, which often causes entire parent trees to re-render needlessly.

It includes concrete code patterns for common fixes. Examples show how to push timer state down into dedicated child components, stabilize handlers using useCallback paired with memo, and compute derived data outside the render cycle. It also covers list windowing and key stability.

Validation relies on the React DevTools Profiler to catch components rendering longer than ~16 ms on the Flamegraph. Blind memoization without baseline profiling often adds memory overhead without fixing the actual lag.

What it helps with

  • isolate ticking timer and animation state into separate child components
  • stabilize callback references and props using useCallback and memo
  • identify components rendering longer than ~16 ms using the profiler
  • avoid heavy recalculations during render with useMemo

Example prompts for the agent

  • Clicking an item in this list causes every row to re-render. Help me optimize the component.
  • A timer in the dashboard header forces a heavy child list to re-render every second. How do I isolate this state?

How to install react-component-performance

1Skills CLI (Vercel)

npx skills add Dimillian/Skills --skill react-component-performance -a claude-code

2Manually: put the files in place

~/.claude/skills/react-component-performance/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/react-component-performance/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about react-component-performance

How to install react-component-performance in Claude Code?

Run npx skills add Dimillian/Skills --skill react-component-performance -a claude-code.

What does react-component-performance do?

It inspects React component performance issues, prevents unnecessary re-renders, and optimizes heavy lists or expensive calculations.

How does the skill validate performance improvements?

It records interactions in the React DevTools Profiler, inspecting the Flamegraph for components rendering longer than ~16 ms and comparing them to baseline metrics.

Source text

SKILL.md · MIT
---
name: react-component-performance
description: Analyze and optimize React component performance issues (slow renders, re-render thrash, laggy lists, expensive computations). Use when asked to profile or improve a React component, reduce re-renders, or speed up UI updates in React apps.
---

# React Component Performance

## Overview

Identify render hotspots, isolate expensive updates, and apply targeted optimizations without changing UI behavior.

## Workflow

1. Reproduce or describe the slowdown.
2. Identify what triggers re-renders (state updates, props churn, effects).
3. Isolate fast-changing state from heavy subtrees.
4. Stabilize props and handlers; memoize where it pays off.
5. Reduce expensive work (computation, DOM size, list length).
6. **Validate**: open React DevTools Profiler → record the interaction → inspect the Flamegraph for components rendering longer than ~16 ms → compare against a pre-optimization baseline recording.

## Checklist

- Measure: use React DevTools Profiler or log renders; capture baseline.
- Find churn: identify state updated on a timer, scroll, input, or animation.
- Split: move ticking state into a child; keep heavy lists static.
- Memoize: wrap leaf rows with `memo` only when props are stable.
- Stabilize props: use `useCallback`/`useMemo` for handlers and derived values.
- Avoid derived work in render: precompute, or compute inside memoized helpers.
- Control list size: window/virtualize long lists; avoid rendering hidden items.
- Keys: ensure stable keys; avoid index when order can change.
- Effects: verify dependency arrays; avoid effects that re-run on every render.
- Style/layout: watch for expensive layout thrash or large Markdown/diff renders.

## Optimization Patterns

### Isolate ticking state

Move a timer or animation counter into a child so the parent list never re-renders on each tick.

```tsx
// ❌ Before – entire parent (and list) re-renders every second
function Dashboard({ items }: { items: Item[] }) {
  const [tick, setTick] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setTick(t => t + 1), 1000);
    return () => clearInterval(id);
  }, []);
  return (
    <>
      <Clock tick={tick} />
      <ExpensiveList items={items} /> {/* re-renders every second */}
    </>
  );
}

// ✅ After – only <Clock> re-renders; list is untouched
function Clock() {
  const [tick, setTick] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setTick(t => t + 1), 1000);
    return () => clearInterval(id);
  }, []);
  return <span>{tick}s</span>;
}

function Dashboard({ items }: { items: Item[] }) {
  return (
    <>
      <Clock />
      <ExpensiveList items={items} />
    </>
  );
}
```

### Stabilize callbacks with `useCallback` + `memo`

```tsx
// ❌ Before – new handler reference on every render busts Row memo
function List({ items }: { items: Item[] }) {
  const handleClick = (id: string) => console.log(id); // new ref each render
  return items.map(item => <Row key={item.id} item={item} onClick={handleClick} />);
}

// ✅ After – stable handler; Row only re-renders when its own item changes
const Row = memo(({ item, onClick }: RowProps) => (
  <li onClick={() => onClick(item.id)}>{item.name}</li>
));

function List({ items }: { items: Item[] }) {
  const handleClick = useCallback((id: string) => console.log(id), []);
  return items.map(item => <Row key={item.id} item={item} onClick={handleClick} />);
}
```

### Prefer derived data outside render

```tsx
// ❌ Before – recomputes on every render
function Summary({ orders }: { orders: Order[] }) {
  const total = orders.reduce((sum, o) => sum + o.amount, 0); // runs every render
  return <p>Total: {total}</p>;
}

// ✅ After – recomputes only when orders changes
function Summary({ orders }: { orders: Order[] }) {
  const total = useMemo(() => orders.reduce((sum, o) => sum + o.amount, 0), [orders]);
  return <p>Total: {total}</p>;
}
```

### Additional patterns

- **Split rows**: extract list rows into memoized components with narrow props.
- **Defer heavy rendering**: lazy-render or collapse expensive content until expanded.

## Profiling Validation Steps

1. Open **React DevTools → Profiler** tab.
2. Click **Record**, perform the slow interaction, then **Stop**.
3. Switch to **Flamegraph** view; any bar labeled with a component and time > ~16 ms is a candidate.
4. Use **Ranked chart** to sort by self render time and target the top offenders.
5. Apply one optimization at a time, re-record, and compare render counts and durations against the baseline.

## Example Reference

Load `references/examples.md` when the user wants a concrete refactor example.

© Dimillian · MIT · Dimillian/Skills

Similar skills

Everything for Frontend and UI →

From the same set11

swift-concurrency-expert Skill reviews and fixes concurrency issues in Swift 6.2+: adds Sendable conformance, applies @MainActor, resolves actor isolation warnings, and migrates completion handlers to async/await. CX Codex +1 2,000installs macos-spm-app-packaging A skill that scaffolds, builds and packages SwiftPM macOS apps without an Xcode project, from the starter layout to signing and notarization. CX Codex +1 1,400installs app-store-changelog Turns commits since your last tag into App Store “What's New” copy. Handy right before you ship a build to the store. CX Codex +1 1,300installs github Guides coding agents to use the gh CLI for inspecting pull requests, issues, and failed CI workflows. CX Codex +1 870installs review-and-simplify-changes Reviews changed code for reuse, quality, efficiency and clarity, then optionally applies safe fixes. Useful right before you commit. CX Codex +1 794installs project-skill-audit Audits past Codex sessions, memory logs, and local skills. It identifies recurring workflows to recommend high-priority skill updates or additions. CX Codex +1 785installs review-swarm Runs a parallel read-only review of a git diff or selected files. Use it to surface regressions, security concerns, and missing test coverage before merging. CX Codex +1 756installs bug-hunt-swarm Investigates bugs with parallel sub-agents and ranks likely root causes. Use it for regressions, crashes, flaky behaviour, and failures when code edits must wait. CX Codex +1 713installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor