PluginBench
Skill
Pass
Audit score 90

react-performance-optimization

nickcrew/claude-cortex

Optimize React apps with memoization, code splitting, and efficient rendering strategies.

What is react-performance-optimization?

Expert guidance for improving React application performance through memoization, code splitting, virtualization, and efficient rendering. Use when optimizing slow components, reducing bundle size, or improving responsiveness with large datasets.

  • Identify performance bottlenecks using React DevTools Profiler
  • Memoize expensive components and computed values with React.memo, useMemo, and useCallback
  • Implement code splitting with React.lazy and Suspense for faster initial loads
  • Virtualize large lists using react-window to render only visible items
  • Optimize state management to minimize unnecessary re-renders
  • Apply concurrent features like useTransition and useDeferredValue for better responsiveness

How to install react-performance-optimization

npx skills add https://github.com/nickcrew/claude-cortex --skill react-performance-optimization
Claude Code
Cursor
Windsurf
Cline

How to use react-performance-optimization

  1. 1.Profile your React application using React DevTools Profiler to identify slow components and unnecessary re-renders
  2. 2.Analyze the flame graph to find bottlenecks and measure baseline performance metrics
  3. 3.Apply targeted optimizations: wrap expensive components with React.memo, cache computed values with useMemo, stabilize function references with useCallback
  4. 4.Implement code splitting for routes and heavy components using React.lazy and Suspense
  5. 5.For large lists (>100 items), integrate react-window for virtualization
  6. 6.Verify improvements by recording a new Profiler session and comparing before/after metrics
  7. 7.Check bundle size reduction using webpack-bundle-analyzer or similar tools

Use cases

Good for
  • Optimizing slow-rendering components in large React applications
  • Reducing initial load time by code-splitting routes and heavy dependencies
  • Improving responsiveness when rendering lists with hundreds or thousands of items
  • Preventing cascading re-renders in complex component trees with shared state
  • Debugging performance issues using React DevTools Profiler flame graphs
Who it's for
  • React developers optimizing existing applications
  • Frontend engineers working on performance-critical features
  • Teams managing large-scale React codebases
  • Developers building data-heavy applications with large lists or tables

react-performance-optimization FAQ

When should I use React.memo vs useMemo vs useCallback?

Use React.memo to prevent re-renders of entire components with stable props. Use useMemo to cache expensive computed values. Use useCallback to create stable function references for memoized child components. Profile first to confirm these optimizations actually help.

How do I know if my component needs optimization?

Use React DevTools Profiler to record interactions and look for components with yellow/red bars (slow renders) or unnecessary renders with unchanged props/state. Only optimize components that actually show performance issues.

What are common mistakes when optimizing React performance?

Over-memoizing fast components adds overhead, inline objects/arrays break memoization, missing dependencies cause stale closures, using array index as key breaks reconciliation, and single large contexts cause widespread re-renders. Always profile before and after optimizing.

How do I virtualize a large list in React?

Use the react-window library with FixedSizeList or VariableSizeList components. Specify height, itemCount, itemSize, and a render function. This renders only visible items, dramatically improving performance for lists with hundreds or thousands of items.

Should I code-split all my routes?

Code-split routes that are not immediately needed on page load, especially heavy components. Use React.lazy and Suspense to load them on demand. Measure bundle size reduction to confirm it improves initial load time.

Full instructions (SKILL.md)

Source of truth, from nickcrew/claude-cortex.


name: react-performance-optimization description: React performance optimization patterns using memoization, code splitting, and efficient rendering strategies. Use when optimizing slow React applications, reducing bundle size, or improving user experience with large datasets. keywords:

  • React optimization
  • React performance
  • React.memo
  • bundle size
  • code splitting
  • lazy loading
  • re-render
  • useCallback
  • useMemo
  • virtualization file_patterns:
  • '**/*.spec.ts'
  • '**/*.test.ts'
  • '**/*.test.tsx'
  • '**/*.ts'
  • '**/*.tsx'
  • '**/package.json'
  • '/tests//*.ts'
  • '/tests//*.tsx'
  • '**/tsconfig.json' confidence: 0.76

React Performance Optimization

Expert guidance for optimizing React application performance through memoization, code splitting, virtualization, and efficient rendering strategies.

When to Use This Skill

  • Optimizing slow-rendering React components
  • Reducing bundle size for faster initial load times
  • Improving responsiveness for large lists or data tables
  • Preventing unnecessary re-renders in complex component trees
  • Optimizing state management to reduce render cascades
  • Improving perceived performance with code splitting
  • Debugging performance issues with React DevTools Profiler

Core Concepts

React Rendering Optimization

React re-renders components when props or state change. Unnecessary re-renders waste CPU cycles and degrade user experience. Key optimization techniques:

  • Memoization: Cache component renders and computed values
  • Code splitting: Load code on demand for faster initial loads
  • Virtualization: Render only visible list items
  • State optimization: Structure state to minimize render cascades

When to Optimize

  1. Profile first: Use React DevTools Profiler to identify actual bottlenecks
  2. Measure impact: Verify optimization improves performance
  3. Avoid premature optimization: Don't optimize fast components

Quick Reference

Load detailed patterns and examples as needed:

TopicReference File
React.memo, useMemo, useCallback patternsskills/react-performance-optimization/references/memoization.md
Code splitting with lazy/Suspense, bundle optimizationskills/react-performance-optimization/references/code-splitting.md
Virtualization for large lists (react-window)skills/react-performance-optimization/references/virtualization.md
State management strategies, context splittingskills/react-performance-optimization/references/state-management.md
useTransition, useDeferredValue (React 18+)skills/react-performance-optimization/references/concurrent-features.md
React DevTools Profiler, performance monitoringskills/react-performance-optimization/references/profiling-debugging.md
Common pitfalls and anti-patternsskills/react-performance-optimization/references/common-pitfalls.md

Optimization Workflow

1. Identify Bottlenecks

# Open React DevTools Profiler
# Record interaction → Analyze flame graph → Find slow components

Look for:

  • Components with yellow/red bars (slow renders)
  • Unnecessary renders (same props/state)
  • Expensive computations on every render

2. Apply Targeted Optimizations

For unnecessary re-renders:

  • Wrap component with React.memo
  • Use useCallback for stable function references
  • Check for inline objects/arrays in props

For expensive computations:

  • Use useMemo to cache results
  • Move calculations outside render when possible

For large lists:

  • Implement virtualization with react-window
  • Ensure proper unique keys (not index)

For slow initial load:

  • Add code splitting with React.lazy
  • Analyze bundle size with webpack-bundle-analyzer
  • Use dynamic imports for heavy dependencies

3. Verify Improvements

# Record new Profiler session
# Compare before/after metrics
# Ensure optimization actually helped

Common Patterns

Memoize Expensive Components

import { memo } from 'react';

const ExpensiveList = memo(({ items, onItemClick }) => {
  return items.map(item => (
    <Item key={item.id} data={item} onClick={onItemClick} />
  ));
});

Cache Computed Values

import { useMemo } from 'react';

function DataTable({ items, filters }) {
  const filteredItems = useMemo(() => {
    return items.filter(item => filters.includes(item.category));
  }, [items, filters]);

  return <Table data={filteredItems} />;
}

Stable Function References

import { useCallback } from 'react';

function Parent() {
  const handleClick = useCallback((id) => {
    console.log('Clicked:', id);
  }, []);

  return <MemoizedChild onClick={handleClick} />;
}

Code Split Routes

import { lazy, Suspense } from 'react';

const Dashboard = lazy(() => import('./Dashboard'));
const Reports = lazy(() => import('./Reports'));

function App() {
  return (
    <Suspense fallback={<Loading />}>
      <Routes>
        <Route path="/" element={<Dashboard />} />
        <Route path="/reports" element={<Reports />} />
      </Routes>
    </Suspense>
  );
}

Virtualize Large Lists

import { FixedSizeList } from 'react-window';

function VirtualList({ items }) {
  return (
    <FixedSizeList
      height={600}
      itemCount={items.length}
      itemSize={80}
      width="100%"
    >
      {({ index, style }) => (
        <div style={style}>{items[index].name}</div>
      )}
    </FixedSizeList>
  );
}

Common Mistakes

  1. Over-memoization: Don't memoize simple, fast components (adds overhead)
  2. Inline objects/arrays: New references break memoization (config={{ theme: 'dark' }})
  3. Missing dependencies: Stale closures in useCallback/useMemo
  4. Index as key: Breaks reconciliation when list order changes
  5. Single large context: Causes widespread re-renders on any update
  6. No profiling: Optimizing without measuring wastes time

Performance Checklist

Before optimizing:

  • Profile with React DevTools to identify bottlenecks
  • Measure baseline performance metrics

Optimization targets:

  • Memoize expensive components with stable props
  • Cache computed values with useMemo (if actually expensive)
  • Use useCallback for functions passed to memoized children
  • Implement code splitting for routes and heavy components
  • Virtualize lists with >100 items
  • Provide stable keys for list items (unique IDs, not index)
  • Split state by update frequency
  • Use concurrent features (useTransition, useDeferredValue) for responsiveness

After optimizing:

  • Profile again to verify improvements
  • Check bundle size reduction (if applicable)
  • Ensure no regressions in functionality

Resources