> react-performance
Optimization strategies for React applications (Client & Server). Use when optimizing React rendering performance, reducing re-renders, or improving bundle size. (triggers: **/*.tsx, **/*.jsx, waterfall, bundle, lazy, suspense, dynamic)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/react-performance?format=md"React Performance
Priority: P0 (CRITICAL)
Strategies to minimize waterfalls, bundle size, and render cost.
Elimination of Waterfalls (P0)
- Parallel Data: Use
Promise.allfor independent fetches. Avoid sequentialawait. - Preload: Start fetches before render (in event handlers or route loaders).
- Suspense: Use Suspense boundaries to stream partial content.
Bundle Optimization (P0)
- No Barrel Files: Import directly
import { Btn } from './Btn'vsimport { Btn } from './components'. - Lazy Load:
React.lazy/next/dynamicfor heavy components (Charts, Modals). - Defer: Load 3rd-party scripts (Analytics) after hydration.
Rendering & Re-renders (P1)
- Isolation: Move state down. Isolate heavy UI updates.
- Context Splitting: Split Context into
StateContext(Data) andDispatchContext(Actions) to prevent consumers from re-rendering just because they need a setter. - Stability: Use
useMemofor passing objects/arrays to children to preserve referential equality checks (React.memo). - Virtualization:
react-windowfor lists > 50 items. - Content Visibility:
content-visibility: autofor off-screen CSS content. - Static Hoisting: Extract static objects/JSX outside component scope.
- Transitions:
startTransitionfor non-urgent UI updates.
Parallelization (P1)
- Web Workers: Move heavy computation (Encryption, Image processing, Large Data Sorting) off the main thread using
ComlinkorWorker.
Server Performance (RSC) (P1)
- Caching:
React.cachefor per-request deduplication. - Serialization: Minimize props passing to Client Components (only IDs/primitives).
Anti-Patterns
- No
export *: Breaks tree-shaking. - No Sequential Await: Causes waterfalls.
- No Inline Objects:
style={{}}breaks strict equality checks (if memoized). - No Heavy Libs: Avoid moment/lodash (use dayjs/radash).
Code
// Parallel Fetching (Good)
const [user, posts] = await Promise.all([getUser(), getPosts()]);
// Bundle Optimized Import (Good)
import { Button } from './components/Button'; // Not from './components'
// Static Hoist (Good)
const STATIC_CONFIG = { theme: 'dark' };
function Component() {
return <div config={STATIC_CONFIG} />;
}
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)