Agent-skills-standard react-performance
Optimize React rendering, bundle size, and data fetching performance. Use when optimizing React rendering performance, reducing re-renders, or improving bundle size. (triggers: **/*.tsx, **/*.jsx, waterfall, bundle, lazy, suspense, dynamic)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/react/react-performance" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-react-performance && rm -rf "$T"
manifest:
skills/react/react-performance/SKILL.mdsource content
React Performance
Priority: P0 (CRITICAL)
Eliminate Data Waterfalls (P0)
- Parallel Data: Use
for independent fetches. Avoid sequential awaits (Request Waterfalls).Promise.all([getUser(), getProducts(), ...]) - Preload: Start fetches before render (in event handlers or route loaders).
- Suspense: Use Suspense boundaries to stream partial content and show partial content early.
See implementation examples for parallel fetch with Suspense boundary and lazy loading patterns.
Reduce Bundle Size (P0)
- No Barrel Files: Avoid barrel files (importing from index.ts); import directly from component files to improve tree-shaking.
- Lazy Load: Use
orReact.lazy
for heavy components like Charts, Modals, or large libraries.next/dynamic - Dependency Reduction: Replace moment with dayjs or lodash with native/radash to drop bytes. Use
orsource-map-explorer
to find bloat.bundle-visualizer
Minimize Re-renders (P1)
- Isolation: Move state as close to its usage as possible. Isolate heavy UI updates.
- List Performance: Use
orreact-window
for virtualization of lists with 500+ items. Wrap list items inreact-virtual
.React.memo - Context Splitting: Split Context into
andState
objects. This prevents all consumers from re-rendering when only setter needed.Dispatch - Stability: Use
for derived list data and passing stable object/array references to children.useMemo - Content Visibility:
for off-screen CSS content.content-visibility: auto - Static Hoisting: Extract static objects/JSX outside component scope.
- Transitions:
for non-urgent UI updates.startTransition
Parallelize Computation (P1)
- Web Workers: Move heavy computation (Encryption, Image processing, Large Data Sorting) off main thread using
orComlink
.Worker
Optimize Server Components (RSC) (P1)
- Caching:
for per-request deduplication.React.cache - Serialization: Minimize props passing to Client Components (only IDs/primitives).
Anti-Patterns
- No
: Breaks tree-shaking.export * - No Sequential Await: Causes waterfalls.
- No Inline Objects:
breaks strict equality checks (if memoized).style={{}} - No Heavy Libs: Avoid moment/lodash (use dayjs/radash).
References
See references/REFERENCE.md for Profiler usage, bundle analysis, Web Workers, and debounce patterns.