react-performance-optimization
nickcrew/claude-ctx-plugin
Optimize React performance with memoization, code splitting, and efficient rendering strategies.
What is react-performance-optimization?
Expert guidance for optimizing React application performance through memoization, code splitting, virtualization, and efficient rendering strategies. Use when optimizing slow-rendering components, reducing bundle size, or improving responsiveness with large datasets.
- Identify rendering bottlenecks using React DevTools Profiler
- Apply memoization patterns (React.memo, useMemo, useCallback) to prevent unnecessary re-renders
- 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 render cascades
- Debug performance issues and measure optimization impact
How to install react-performance-optimization
npx skills add https://github.com/nickcrew/claude-ctx-plugin --skill react-performance-optimizationHow to use react-performance-optimization
- 1.Profile your React application using React DevTools Profiler to identify slow components
- 2.Analyze the flame graph to find components with yellow/red bars indicating performance issues
- 3.Apply targeted optimizations: wrap expensive components with React.memo, cache computations with useMemo, stabilize function references with useCallback
- 4.Implement code splitting with React.lazy for routes or heavy components
- 5.For large lists (>100 items), integrate react-window for virtualization
- 6.Re-profile after optimizations to verify improvements and measure impact
- 7.Check bundle size reduction using webpack-bundle-analyzer or similar tools
Use cases
- Optimizing slow-rendering React components in production applications
- Reducing bundle size for faster initial page load times
- Improving responsiveness when rendering large lists or data tables
- Preventing unnecessary re-renders in complex component trees with multiple state updates
- Implementing code splitting for route-based or feature-based lazy loading
- React developers optimizing application performance
- Frontend engineers working with large datasets or complex component hierarchies
- Teams focused on improving Core Web Vitals and user experience metrics
react-performance-optimization FAQ
Use React.memo to memoize entire components and prevent re-renders when props haven't changed. Use useMemo to cache expensive computed values within a component. Use useCallback to create stable function references for functions passed to memoized children. Always profile first to ensure the optimization actually helps.
Over-memoizing fast components adds unnecessary overhead. Passing inline objects/arrays as props breaks memoization. Missing dependency arrays in useCallback/useMemo causes stale closures. Using array index as key breaks reconciliation. Creating a single large context causes widespread re-renders on any update.
Use React DevTools Profiler to record a session before and after optimization, then compare render times and frequency. For bundle size, use webpack-bundle-analyzer or rollup-plugin-visualizer. Measure real-world metrics like Lighthouse scores or Core Web Vitals.
Implement virtualization with react-window when rendering lists with more than 100 items. Virtualization renders only visible items, dramatically improving performance for large datasets.
Use React.lazy() to dynamically import components and wrap routes with Suspense. This loads code on-demand rather than bundling everything upfront, reducing initial bundle size and improving time-to-interactive.
Full instructions (SKILL.md)
Source of truth, from nickcrew/claude-ctx-plugin.
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
- Profile first: Use React DevTools Profiler to identify actual bottlenecks
- Measure impact: Verify optimization improves performance
- Avoid premature optimization: Don't optimize fast components
Quick Reference
Load detailed patterns and examples as needed:
| Topic | Reference File |
|---|---|
| React.memo, useMemo, useCallback patterns | skills/react-performance-optimization/references/memoization.md |
| Code splitting with lazy/Suspense, bundle optimization | skills/react-performance-optimization/references/code-splitting.md |
| Virtualization for large lists (react-window) | skills/react-performance-optimization/references/virtualization.md |
| State management strategies, context splitting | skills/react-performance-optimization/references/state-management.md |
| useTransition, useDeferredValue (React 18+) | skills/react-performance-optimization/references/concurrent-features.md |
| React DevTools Profiler, performance monitoring | skills/react-performance-optimization/references/profiling-debugging.md |
| Common pitfalls and anti-patterns | skills/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
useCallbackfor stable function references - Check for inline objects/arrays in props
For expensive computations:
- Use
useMemoto 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
- Over-memoization: Don't memoize simple, fast components (adds overhead)
- Inline objects/arrays: New references break memoization (
config={{ theme: 'dark' }}) - Missing dependencies: Stale closures in useCallback/useMemo
- Index as key: Breaks reconciliation when list order changes
- Single large context: Causes widespread re-renders on any update
- 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
- React Docs - Performance: https://react.dev/learn/render-and-commit
- React DevTools: Browser extension for profiling
- react-window: https://github.com/bvaughn/react-window
- Bundle analyzers: webpack-bundle-analyzer, rollup-plugin-visualizer
- Lighthouse: Chrome DevTools performance audit
Related skills
More from nickcrew/claude-ctx-plugin and the wider catalog.

owasp-top-10
OWASP Top 10 security vulnerabilities with detection and remediation patterns. Use when conducting security audits, implementing secure coding practices, or reviewing code for common security vulnerabilities.

prompt-master
Generate optimized prompts for AI tools—write, fix, and improve prompts for LLMs, Cursor, Midjourney, and more.

codex-ppt
Generate visually unified image-based PowerPoint decks from articles, reports, and notes.

shadcn-vue
shadcn-vue for Vue/Nuxt with Reka UI components and Tailwind. Use for accessible UI, Auto Form, data tables, charts, dark mode, MCP server setup, or encountering component imports, Reka UI errors.

createos
Deploy any code to production on CreateOS—AI agents, APIs, bots, frontends, and more.

tauri-v2
Build cross-platform desktop and mobile apps with Rust backends and web frontends using Tauri v2+.