ktaesthetix

Vercel Composition Patterns

开发编程v1.0.0
作者:ktaesthetix更新于 2026-05-11vercel-composition-patterns@clawhub_ktaesthetix/vercel-composition-patterns
代码生成前端开发

据 AlphaMoat 统计,截至 2026-09,Vercel Composition Patterns 累计下载 4,964 次、获 4 个星标,在全部 5,078 个 AI 技能中排名第 1,856 位,在「开发编程」分类(577 个)中排名第 240 位。

累计安装
466
累计下载
4,964
星标
4
全站排名
#1,856
全站前 37% · 「开发编程」前 42%
平台累计安装累计下载星标评论
ClawHub ↗1534,5794-
SkillHub ↗4664,9643—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

通过复合组件与共享上下文减少布尔属性堆积,将状态实现封装在 Provider 后,并采用显式变体和基于子组件的组合方式。指南还标注了特定 React 版本的 API 规则,仅应在其声明支持的版本中应用。 应用 React 19 特有的 ref、context 或 use() 建议前,先核对项目版本。

资料发布于 2026-10-27

可以用来做什么

  • 审阅组件接口并重构布尔属性过多的组件

什么时候用

  • 设计组件库或审阅 React 组合架构时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

审阅这个组件,提出适合其 React 版本的复合组件与显式变体方案。

月度数据趋势

累计下载4,964
3,0834,0935,1032026-03 · 累计下载 3,2222026-05 · 累计下载 3,8532026-06 · 累计下载 4,0432026-07 · 累计下载 4,3392026-08 · 累计下载 4,4882026-09 · 累计下载 4,96426-0326-09
星标4
3442026-03 · 星标 32026-05 · 星标 32026-06 · 星标 32026-07 · 星标 32026-08 · 星标 42026-09 · 星标 426-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-094,964—4
2026-084,488+3.4%4
2026-074,339+7.3%3
2026-064,043+4.9%3
2026-053,853—3
2026-033,222—3

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

2.8 KB · ClawHub v1.0.0
---
name: vercel-composition-patterns
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.
license: MIT
metadata:
展开全部(共 90 行)
  author: vercel
  version: '1.0.0'
---

# 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`

「开发编程」分类下的热门技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。