Loading...
Loading...
React performance optimization patterns including memoization, code splitting, bundle size reduction, re-render elimination, and profiling. Covers React Compiler automatic optimization, manual memo/useMemo/useCallback targeting, React.lazy with Suspense, barrel file avoidance, content-visibility for large lists, startTransition for non-urgent updates, and React DevTools profiling. Use when optimizing React app performance, reducing bundle size, eliminating unnecessary re-renders, debugging slow components, code splitting, or profiling rendering bottlenecks. Use for performance audit, bundle analysis, re-render diagnosis, lazy loading, virtualization.
npx skill4agent add oakoss/agent-skills react-performancereact-patterns| Category | Technique | Key Points |
|---|---|---|
| Compiler | React Compiler | Automatic memoization at build time; eliminates manual memo/useMemo/useCallback |
| Memoization | | Wrap components receiving stable primitive props from frequently re-rendering parents |
| Memoization | | Expensive computations only: sorting, filtering, Set/Map construction |
| Memoization | | Only when passed to memoized children; use functional setState for stable refs |
| Splitting | | Lazy-load heavy components with |
| Splitting | Preload on intent | Trigger |
| Bundle | Direct imports | Avoid barrel files; import from specific paths to reduce module count |
| Bundle | Defer third-party | Load analytics, logging after hydration |
| Re-renders | | Mark non-urgent updates (search, scroll tracking) as interruptible |
| Re-renders | Functional setState | |
| Re-renders | Derived state | Subscribe to booleans, not continuous values; compute during render |
| Re-renders | Defer state reads | Read dynamic state (searchParams) inside callbacks, not at render |
| Rendering | | Skip layout/paint for off-screen items in long lists |
| Rendering | Hoist static JSX | Extract constant elements outside component functions |
| Profiling | React DevTools Profiler | Record renders, identify slow components, flamegraph analysis |
| Profiling | Bundle analyzer | Visualize chunk sizes, find oversized dependencies |
| Mistake | Correct Pattern |
|---|---|
| Wrapping everything in useMemo/useCallback | Trust React Compiler first; only memoize expensive computations or memoized-child callbacks |
Memoizing cheap operations like | Skip memo for simple primitives; overhead exceeds recomputation cost |
Importing from barrel files ( | Import directly from specific paths or use |
| Loading analytics/tracking in the initial bundle | Defer with lazy + mounted state to load after hydration |
| Subscribing to continuous values (window width) for boolean checks | Use |
| Referencing state in useCallback dependency array | Use functional setState |
Using | Compute derived values during render; effects add an extra render cycle |
| Creating new object literals as props on every render | Hoist static objects outside component; use useMemo for dynamic objects |
| Profiling in development mode | Always profile production builds; dev mode includes extra warnings that skew results |
ExploreTaskPlanIf theskill is available, delegate general component architecture and React 19 API questions to it. Otherwise, recommend:react-patternsnpx skills add oakoss/agent-skills --skill react-patterns