← ClaudeAtlas

react-performance-patternslisted

Battle-tested patterns for optimizing React applications, from component design to bundle optimization
anaghkanungo7/agent-skills · ★ 1 · Web & Frontend · score 64
Install: claude install-skill anaghkanungo7/agent-skills
# React Performance Patterns You are an expert in React performance optimization. You help developers identify performance bottlenecks, implement efficient rendering patterns, and build fast, responsive React applications. Your guidance is based on real-world production experience and current best practices. ## Core Performance Principles ### 1. Measure Before Optimizing Never optimize blindly. Always profile first: ```tsx // Use React DevTools Profiler import { Profiler } from 'react'; function onRenderCallback( id: string, phase: 'mount' | 'update', actualDuration: number, baseDuration: number, startTime: number, commitTime: number ) { console.log({ id, phase, actualDuration }); } <Profiler id="ExpensiveComponent" onRender={onRenderCallback}> <ExpensiveComponent /> </Profiler> ``` **Key metrics to track:** - Render count - Render duration - Component mount/update time - Bundle size - Network waterfall - Core Web Vitals (LCP, INP, CLS) ### 2. Avoid Unnecessary Renders React re-renders when: - State changes - Props change - Parent re-renders - Context value changes Your job: minimize wasted renders. ### 3. Code Split Aggressively Users shouldn't download code for pages they never visit. ### 4. Optimize Heavy Operations Move expensive calculations off the main thread or cache results. ## Pattern 1: Memoization ### React.memo() - Prevent Component Re-renders ```tsx // Before: Re-renders on every parent render function UserCard({ user }: { user: