Skill

Optimize React Component Performance

Diagnoses and fixes React re-render performance issues via a checklist, Profiler workflow, and before/after code patterns.

Works with react

91
Spark score
out of 100
Updated 29 days ago
Version 14.1.0

Add to Favorites

Why it matters

Improve the performance of your React applications by identifying and resolving render bottlenecks. This skill helps reduce re-renders, eliminate lag, and optimize expensive computations without altering the user interface.

Outcomes

What it gets done

01

Profile React components to find render hotspots.

02

Isolate and optimize expensive updates and re-renders.

03

Apply memoization and state stabilization techniques.

04

Validate optimizations using React DevTools Profiler.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-react-component-performance | bash

Overview

React Component Performance

A React performance skill that diagnoses render hotspots via DevTools Profiler and fixes them with memo, useCallback, and useMemo patterns. Use when a React component or list is slow to render or re-renders more than necessary; not a substitute for environment-specific testing of the fix.

What it does

Diagnoses and fixes React render performance problems without changing UI behavior: identifies render hotspots, isolates expensive updates from fast-changing state, and applies targeted optimizations. It follows a six-step workflow - reproduce or describe the slowdown, identify what triggers re-renders (state updates, props churn, effects), isolate fast-changing state from heavy subtrees, stabilize props and handlers with memoization where it pays off, reduce expensive work, then validate in React DevTools Profiler by recording the interaction and inspecting the Flamegraph for components rendering longer than ~16ms against a pre-optimization baseline. A ten-item checklist covers measuring baselines, finding state-churn sources such as timers, scroll, input, or animation, splitting ticking state into a child component, memoizing leaf rows only when props are stable, stabilizing handlers and derived values with useCallback/useMemo, avoiding derived work inside render, virtualizing long lists, using stable keys instead of array index, auditing effect dependency arrays, and watching for layout thrash or large Markdown/diff renders. It demonstrates three before/after optimization patterns with full code: isolating a ticking timer into its own child component so a heavy list no longer re-renders every second, stabilizing a click handler with useCallback so a memo-wrapped row only re-renders when its own item changes, and moving a derived total computation into useMemo so it recomputes only when its dependency changes.

When to use - and when NOT to

Use it when a user asks to profile or improve a slow React component, or needs to reduce re-renders, list lag, or expensive render work in a React UI. The skill is scoped to render-performance diagnosis and targeted fixes - it explicitly defers deeper worked examples to a separate references/examples.md file rather than duplicating that content inline, and does not claim to substitute for environment-specific validation, testing, or expert review of the resulting changes.

Inputs and outputs

Input is a description of a slow React component or interaction, or profiler data from an existing slowdown. Output is a set of targeted code changes following the documented patterns, for example:

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} />);
}

plus a validation pass comparing Profiler Flamegraph render counts and durations before and after the change.

Integrations

Built around React's own performance primitives - memo, useCallback, useMemo, and the React DevTools Profiler's Flamegraph and Ranked chart views - with no external libraries required beyond React itself.

Who it's for

Frontend engineers diagnosing and fixing React re-render performance issues - slow lists, laggy interactions, or components that re-render more than their underlying data actually changes.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.