帮助你编写或审查符合 React 18/19 最佳实践的组件与架构。
该技能材料显示其为纯提示词/文档型 React 模式指南,无需密钥、未声明远程端点,也未体现可执行或数据外发能力。结合开源且社区采用度很高的正面证据,整体属于低风险。
材料明确注明无需密钥或环境变量;作为提示词/文档型技能,未见凭证收集、存储或调用第三方账号的设计。
未声明任何远程端点或联网行为;内容仅为 React 编码模式说明,未见将用户数据发送到外部服务的事实。
系统检查项为 prompt-only,材料也仅包含说明与示例代码片段;未显示会在本机启动进程、执行脚本或调用系统能力。
未描述任何文件读写、本地资源访问或数据库操作权限;示例中的代码仅用于教学说明,不代表该技能本身具备数据访问能力。
来源为 GitHub 开源仓库,且社区采用度极高(约 21 万 star),这些都是明显的降风险因素。许可证与维护状态未明,值得后续核验,但仅凭现有材料未见闭源、失维或可疑分发红旗。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "react-patterns" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/react-patterns/SKILL.md 2. 保存为 ~/.claude/skills/react-patterns/SKILL.md 3. 装好后重载技能,告诉我可以用了
请审查下面这个 React 组件方案,重点检查 hooks 使用纪律、Server/Client Component 边界、Suspense 与 Error Boundary 的放置是否合理,并给出重构建议与示例代码: [粘贴组件代码或设计方案]
一份结构化审查意见,指出边界问题、潜在风险以及改进后的组件组织方式与代码示例。
我正在做一个 React 19 应用,包含表单提交、服务端数据获取、局部 UI 状态和跨页面共享状态。请根据场景给出状态管理决策树,说明何时用 useState、useReducer、context、URL 状态、服务端数据缓存或外部状态库。
一份按场景分类的状态管理决策建议,包含选择标准、取舍分析和推荐方案。
请为这个 React 表单重写实现方案,要求优先考虑可访问性,使用现代表单 actions 模式,处理提交中、成功、失败三种状态,并说明如何让键盘与屏幕阅读器体验更好: [粘贴表单代码]
一个改进后的表单实现方案,包含可访问交互说明、状态处理逻辑和示例代码。
Idiomatic React 18/19 patterns for building robust, accessible, performant component trees.
forwardRef/useEffect-heavy code// Good: derive during render
function Cart({ items }: { items: CartItem[] }) {
const total = items.reduce((sum, i) => sum + i.price * i.qty, 0);
return <span>{formatMoney(total)}</span>;
}
// Bad: derived state stored separately
function Cart({ items }: { items: CartItem[] }) {
const [total, setTotal] = useState(0);
useEffect(() => {
setTotal(items.reduce((sum, i) => sum + i.price * i.qty, 0));
}, [items]);
return <span>{formatMoney(total)}</span>;
}
Derived state in useEffect adds a render cycle, can desync, and obscures the data flow.
Effects, mutations, network calls, and subscriptions live in event handlers or useEffect — never in the render body.
React has no inheritance model for components. Compose with children, render props, or component props.
See rules/react/hooks.md for the full ruleset. Highlights:
setX(prev => prev + 1)) when new state depends on olduseMemo/useCallback only when a profiler or a dependency chain proves it mattersUsed by one component?
-> useState inside it
Used by parent + a few descendants?
-> lift to nearest common ancestor
Used across distant branches AND low-frequency reads (theme, auth, locale)?
-> React Context
High-frequency updates shared across the tree?
-> external store (Zustand, Jotai, Redux Toolkit)
Derived from a server?
-> server-state library (TanStack Query, SWR, RSC fetch)
Most pages do not need context or a global store. Resist abstraction until duplicated lifting becomes painful.
// Server Component - default, async, never ships JS for itself
export default async function ProductPage({ params }: { params: { id: string } }) {
const product = await db.product.findUnique({ where: { id: params.id } });
if (!product) notFound();
return <ProductView product={product} />;
}
// Client Component - opt in with "use client"
"use client";
export function AddToCartButton({ productId }: { productId: string }) {
const [pending, startTransition] = useTransition();
return (
<button
disabled={pending}
onClick={() => startTransition(() => addToCart(productId))}
>
{pending ? "Adding..." : "Add to cart"}
</button>
);
}
Boundaries:
children<form action={...}> or imperatively from event handlersimport a Server Component from a Client Component file — compose them via children instead<ErrorBoundary fallback={<ErrorView />}>
<Suspense fallback={<UserSkeleton />}>
<UserDetail id={id} />
</Suspense>
</ErrorBoundary>
…
帮助你设计与优化 Spring Boot 后端架构、接口与服务实现。
帮助你设计可组合的推荐、排序与信息流 Top K 决策流水线
为 orch 系列技能统一编排研发流程与人工审批关卡
基于多源网页检索与综合分析,生成带引用和来源标注的深度研究报告
用于管理 Uncloud 集群,完成部署、入口配置、扩缩容与运维排障。
调用 Nutrient DWS API 处理文档转换、OCR提取、脱敏签署与表单填写
帮助你在编写、审查或重构 React/Next.js 代码时系统优化性能。
帮助你梳理 React 与 Next.js 前端模式、状态管理及性能优化最佳实践
帮助你为 React 组件、Hook 与页面编写、修复并优化测试方案。
帮助开发者为 React 与 Next.js 交互界面实现无障碍设计与可用性优化。
帮助开发者构建 React 微前端架构,并实现共享依赖、动态表单与状态管理。
提供 Nuxt 4 的 SSR 安全、性能优化与数据获取最佳实践模式