AGENT SKILL

React 组件组合模式设计

vercel-composition-patterns

可扩展的 React 组件组合模式。当重构存在布尔属性泛滥的组件、构建灵活的组件库或设计可复用 API 时使用。适用于涉及复合组件、渲染属性(render props)、上下文提供者(context providers)或组件架构的任务。包含 React 19 API 变更。

License 许可
MIT
最近更新
2026-09-02
Stars
★ 0
Forks
0

01 前言 Front Matter

name
vercel-composition-patterns
license
MIT
metadata
{ "author": "vercel", "version": "1.0.0" }
description
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

02 资源文件 11

03 SKILL.md 正文

React Composition Patterns

Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. These patterns make codebases easier for both humans and AI agents to work with as they scale.

When to Apply

Reference these guidelines when:

  • Refactoring components with many boolean props
  • Building reusable component libraries
  • Designing flexible component APIs
  • Reviewing component architecture
  • Working with compound components or context providers

Rule Categories by Priority

Priority Category Impact Prefix
1 Component Architecture HIGH architecture-
2 State Management MEDIUM state-
3 Implementation Patterns MEDIUM patterns-
4 React 19 APIs MEDIUM react19-

Quick Reference

1. Component Architecture (HIGH)

  • architecture-avoid-boolean-props - Don't add boolean props to customize behavior; use composition
  • architecture-compound-components - Structure complex components with shared context

2. State Management (MEDIUM)

  • state-decouple-implementation - Provider is the only place that knows how state is managed
  • state-context-interface - Define generic interface with state, actions, meta for dependency injection
  • state-lift-state - Move state into provider components for sibling access

3. Implementation Patterns (MEDIUM)

  • patterns-explicit-variants - Create explicit variant components instead of boolean modes
  • patterns-children-over-render-props - Use children for composition instead of renderX props

4. React 19 APIs (MEDIUM)

⚠️ React 19+ only. Skip this section if using React 18 or earlier.

  • react19-no-forwardref - Don't use forwardRef; use use() instead of useContext()

How to Use

Read individual rule files for detailed explanations and code examples:

rules/architecture-avoid-boolean-props.md
rules/state-context-interface.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

04 同仓库更多 Skills

epiphanyapps
epiphanyapps/mapyourhealth

Claude 技能规范校验

validate-skills

依据 agentskills.io 规范和 Claude Code 最佳实践校验本仓库中的技能。通过 /validate-skills 命令使用。

AI 工程师插件与技能管理
★ 0
epiphanyapps
epiphanyapps/mapyourhealth

Expo DOM 组件跨端迁移

use-dom

使用 Expo DOM 组件在原生平台的 webview 中运行 Web 代码,并在 Web 端按原样运行。用于以增量方式将 Web 代码迁移到原生。

软件开发工程师移动应用开发
★ 0
epiphanyapps
epiphanyapps/mapyourhealth

React Native 版本升级

upgrading-react-native

React Native 升级工作流,涵盖更新的模板、依赖和常见陷阱。用于将 React Native 应用迁移到更新的版本。

软件开发工程师依赖升级与管理
★ 0
epiphanyapps
epiphanyapps/mapyourhealth

upgrading-expo

Guidelines for upgrading Expo SDK versions and fixing dependency issues

★ 0
epiphanyapps
epiphanyapps/mapyourhealth

React Native 性能优化

react-native-best-practices

提供 React Native 性能优化指南,涵盖 FPS、TTI、bundle 体积、内存泄漏、重复渲染和动画。适用于涉及 Hermes 优化、JS 线程阻塞、bridge 开销、FlashList、原生模块或调试卡顿与掉帧的任务。

软件开发工程师性能剖析与优化
★ 0
epiphanyapps
epiphanyapps/mapyourhealth

网络请求与数据获取

native-data-fetching

用于实现或调试任何网络请求、API 调用或数据获取。涵盖 fetch API、axios、React Query、SWR、错误处理、缓存策略、离线支持。

软件开发工程师前端开发与界面实现
★ 0