Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计通过

react-patternsReact 模式

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

13,077

周安装

556

GitHub Stars

750

下载量

4,581
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-patterns(React 模式)
来源仓库:https://github.com/jezweb/claude-skills
仓库路径:skills/react-patterns
安装命令:
npx skills add https://github.com/jezweb/claude-skills --skill react-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/jezweb/claude-skills --skill react-patterns

简介

用于辅助前端页面、组件和样式开发与维护。

  • 适合生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码。
  • 需结合项目现有设计系统和路由方式,避免生成孤立片段。
  • 涉及页面改动时,应配合本地预览和构建检查确认视觉效果。
  • react-patterns 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

React Patterns

Performance and composition patterns for React 19 + Vite + Cloudflare Workers projects. Use as a checklist when writing new components, a review guide when auditing existing code, or a refactoring playbook when something feels slow or tangled.

Rules are ranked by impact. Fix CRITICAL issues before touching MEDIUM ones.

When to Apply

  • Writing new React components or pages
  • Reviewing code for performance issues
  • Refactoring components with too many props or re-renders
  • Debugging "why is this slow?" or "why does this re-render?"
  • Building reusable component libraries
  • Code review before merging

1. Eliminating Waterfalls (CRITICAL)

Sequential async calls where they could be parallel. The #1 performance killer.

PatternProblemFix
Await in sequenceconst a = await getA(); const b = await getB();const [a, b] = await Promise.all([getA(), getB()]);
Fetch in childParent renders, then child fetches, then grandchild fetchesHoist fetches to the highest common ancestor, pass data down
Suspense cascadeMultiple Suspense boundaries that resolve sequentiallyOne Suspense boundary wrapping all async siblings
Await before branchconst data = await fetch(); if (condition) {use(data);}Move await inside the branch — don't fetch what you might not use
Import then renderconst Component = await import('./Heavy'); return <Component />Use React.lazy() + <Suspense> — renders fallback instantly

How to find them: Search for await in components. Each await is a potential waterfall. If two awaits are independent, they should be parallel.

2. Bundle Size (CRITICAL)

Every KB the user downloads is a KB they wait for.

PatternProblemFix
Barrel importsimport {Button} from '@/components' pulls the entire barrel fileimport {Button} from '@/components/ui/button' — direct import
No code splittingHeavy component loaded on every pageReact.lazy(() => import('./HeavyComponent')) + <Suspense>
Third-party at loadAnalytics/tracking loaded before the app rendersLoad after hydration: useEffect(() => {import('./analytics')}, [])
Full library importimport _ from 'lodash' (70KB)import debounce from 'lodash/debounce' (1KB)
Lucide tree-shakingimport * as Icons from 'lucide-react' (all icons)Explicit map: import {Home, Settings} from 'lucide-react'
Duplicate ReactLibrary bundles its own React → "Cannot read properties of null"resolve.dedupe: ['react', 'react-dom'] in vite.config.ts

How to find them: npx vite-bundle-visualizer — shows what's in your bundle.

3. Composition Architecture (HIGH)

How you structure components matters more than how you optimise them.

PatternProblemFix
Boolean prop explosion<Card isCompact isClickable showBorder hasIcon isLoading>Explicit variants: <CompactCard>, <ClickableCard>
Compound componentsComplex component with 15 propsSplit into <Dialog>, <Dialog.Trigger>, <Dialog.Content> with shared context
renderX props<Layout renderSidebar={...} renderHeader={...} renderFooter={...}>Use children + named slots: <Layout><Sidebar /><Header /></Layout>
Lift stateSibling components can't share stateMove state to parent or context provider
Provider implementationConsumer code knows about state management internalsProvider exposes interface {state, actions, meta} — implementation hidden
Inline componentsfunction Parent() {function Child() {...} return <Child />}Define Child outside Parent — inline components remount on every render

The test: If a component has more than 5 boolean props, it needs composition, not more props.

4. Re-render Prevention (MEDIUM)

Not all re-renders are bad. Only fix re-renders that cause visible jank or wasted computation.

PatternProblemFix
Default object/array propsfunction Foo({items = []}) → new array ref every renderHoist: const DEFAULT = []; function Foo({items = DEFAULT})
Derived state in effectuseEffect(() => setFiltered(items.filter(...)), [items])Derive during render: const filtered = useMemo(() => items.filter(...), [items])
Object dependencyuseEffect(() => {...}, [config]) fires every render if config is {}Use primitive deps: useEffect(() => {...}, [config.id, config.type])
Subscribe to unused stateComponent reads {user, theme, settings} but only uses userSplit context or use selector: useSyncExternalStore
State for transient valuesconst [mouseX, setMouseX] = useState(0) on mousemoveUse useRef for values that change frequently but don't need re-render
Inline callback props<Button onClick={() => doThing(id)} /> — new function every renderuseCallback or functional setState: <Button onClick={handleClick} />

How to find them: React DevTools Profiler → "Why did this render?" or <React.StrictMode> double-renders in dev.

5. React 19 Specifics (MEDIUM)

Patterns that changed or are new in React 19.

PatternOld (React 18)New (React 19)
Form stateuseFormStateuseActionState — renamed
Ref forwardingforwardRef((props, ref) =>...)function Component({ref,...props}) — ref is a regular prop
ContextuseContext(MyContext)use(MyContext) — works in conditionals and loops
Pending UIManual loading stateuseTransition + startTransition for non-urgent updates
Route-level lazyWorks with createBrowserRouter onlyStill true — <Route lazy={...}> is silently ignored with <BrowserRouter>
Optimistic updatesManual state managementuseOptimistic hook
MetadataHelmet or manual <head> management<title>, <meta>, <link> in component JSX — hoisted to <head> automatically

6. Rendering Performance (MEDIUM)

PatternProblemFix
Layout shift on loadContent jumps when async data arrivesSkeleton screens matching final layout dimensions
Animate SVG directlyJanky SVG animationWrap in <div>, animate the div instead
Large list rendering1000+ items in a table/list@tanstack/react-virtual for virtualised rendering
content-visibilityLong scrollable content renders everything upfrontcontent-visibility: auto on off-screen sections
Conditional render with &&{count && <Items />} renders 0 when count is 0Use ternary: {count > 0? <Items />: null}

7. Data Fetching (MEDIUM)

PatternProblemFix
No deduplicationSame data fetched by 3 componentsTanStack Query or SWR — automatic dedup + caching
Fetch on mountuseEffect(() => {fetch(...)}, []) — waterfalls, no caching, no dedupTanStack Query: useQuery({queryKey: ['users'], queryFn: fetchUsers})
No optimistic updateUser clicks save, waits 2 seconds, then sees changeuseMutation with onMutate for instant visual feedback
Stale closure in intervalsetInterval captures stale stateuseRef for the interval ID and current values
Polling without cleanupsetInterval in useEffect without clearIntervalReturn cleanup: useEffect(() => {const id = setInterval(...); return () => clearInterval(id);})

8. Vite + Cloudflare Specifics (MEDIUM)

PatternProblemFix
import.meta.env in Node scriptsUndefined — only works in Vite-processed filesUse loadEnv() from vite
React duplicate instanceLibrary bundles its own Reactresolve.dedupe + optimizeDeps.include in vite.config.ts
Radix Select empty string<SelectItem value=""> throwsUse sentinel: <SelectItem value="__any__">
React Hook Form null{...field} passes null to InputSpread manually: value={field.value?? ''}
Env vars at edgeprocess.env doesn't exist in WorkersUse c.env (Hono context) or import.meta.env (Vite build-time)

Using as a Review Checklist

When reviewing code, go through categories 1-3 (CRITICAL + HIGH) for every PR. Categories 4-8 only when performance is a concern.

/react-patterns [file or component path]

Read the file, check against rules in priority order, report findings as:

file:line — [rule] description of issue

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.48%
按下载量换算1,625

Claude

32.18%
按下载量换算1,474

Cursor

19.73%
按下载量换算904

Gemini CLI

9.23%
按下载量换算423

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills