react
БесплатноБез исполняемых скриптовНе проверенHow to use React. Use when working on a React codebase.
от elentok★ 25 звёзд на GitHubОб этом скилле
React Best Practices & Composition Patterns
Based on Vercel Agent Skills
Part 1: React Best Practices
1. Eliminating Waterfalls (CRITICAL)
- Defer await until needed — move
awaitinto the branch that uses the result; don't block early-return paths. - Parallelize with
Promise.all()— neverawaitindependent operations sequentially; run them concurrently. - Dependency-based parallelization — for partial dependencies, start promises eagerly and
Promise.all()at the end:const userPromise = fetchUser() const profilePromise = userPromise.then((u) => fetchProfile(u.id)) const [user, config, profile] = await Promise.all([userPromise, fetchConfig(), profilePromise]) - Strategic Suspense boundaries — wrap only the data-dependent section in
<Suspense>so layout renders immediately. Share promises across sibling components viause().
2. Bundle Size Optimization (CRITICAL)
- Avoid barrel file imports — import directly from source (
lucide-react/dist/esm/icons/check) instead of barrel re-exports. Barrel imports can load 1,500+ modules. - Dynamic imports for heavy components — use
React.lazy/next/dynamicwith{ ssr: false }for large components (editors, charts). - Defer non-critical libraries — load analytics/logging after hydration via dynamic import.
- Preload on user intent — trigger
import()ononMouseEnter/onFocusto reduce perceived latency. - Conditional module loading —
import()large data/modules only when a feature is activated.
3. Server-Side Performance (HIGH)
- Authenticate Server Actions — treat
"use server"functions as public endpoints; always verify auth + authorization inside each action. - Minimize serialization at RSC boundaries — only pass the fields the client component actually uses, not entire objects.
- Parallel data fetching with component composition — make the parent a sync component that renders async children in parallel (not a sequential async parent).
- Per-request dedup with
React.cache()— wrap DB queries/auth checks; avoid inline objects as args (usesObject.is). - Hoist static I/O to module level — fonts, logos, config files read once at import, not per-request.
- Use
after()for non-blocking ops — schedule logging/analytics after the response is sent.
4. Client-Side Data Fetching (MEDIUM-HIGH)
- Use SWR for automatic request deduplication, caching, and revalidation across component instances.
- Passive event listeners — add
{ passive: true }to touch/wheel listeners that don't callpreventDefault(). - Deduplicate global event listeners — use a shared subscription (e.g.,
useSWRSubscription) instead of N listeners for N component instances. - Version localStorage keys — prefix with version, store minimal fields, always wrap in try-catch.
5. Re-render Optimization (MEDIUM)
- Derive state during render — if computable from props/state, don't store in state or sync via useEffect.
- Don't define components inside components — creates new component type every render, destroying state/DOM.
- Functional
setStateupdates —setState(prev => ...)avoids stale closures and removes state from dependency arrays. - Lazy state initialization —
useState(() => expensive())runs only once; without the arrow, it runs every render. - Split combined hook computations — separate
useMemo/useEffectwith independent deps so they recompute independently. - Subscribe to derived state — e.g.,
useMediaQuery('(max-width:767px)')instead of subscribing to continuouswidthchanges. - Extract default non-primitive values to constants —
const NOOP = () => {}as default prop formemo()'d components. - Use
useReffor transient values — mouse position, interval IDs, flags that shouldn't trigger re-renders. useDeferredValuefor expensive derived renders — keeps input responsive while heavy computation catches up.startTransitionfor non-urgent updates — marks frequent state updates (scroll, resize) as interruptible.- Put interaction logic in event handlers — not as state + effect; avoids duplicate side effects.
6. Rendering Performance (MEDIUM)
- CSS
content-visibility: auto— skip layout/paint for off-screen items in long lists (10× faster initial render for 1000 items). - Animate SVG wrapper div, not SVG element — enables hardware-accelerated CSS transforms.
- Hoist static JSX — extract constant JSX outside components to avoid re-creation.
<Activity mode="visible|hidden">— React API to preserve state/DOM for toggled components.defer/asyncon scripts — never block HTML parsing with synchronous script tags.- Explicit conditional rendering — use ternary (
? :) not&&when condition can be0orNaN. - **React DOM resource
Установить react в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл react?
How to use React. Use when working on a React codebase.
Как установить скилл react?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic