跳到主内容
智客 ZICQ

技能库 智客分类:设计创意 react

React

用于写作,审查,再造,或迁移的现代反应常规 反应:使纯度,"钩子"规则,"你可能不需要一个效果",状态放置, refs,上下文,悬浮数据获取,动作和形式状态,服务器和客户端组件,反应编译器,按角色进行测试. 以“核心类型”和“建筑设计”为基础。 当用户提及 React, hook, use Effect, use State, re-resters, 服务器组件, "使用客户端", Suspense, React 编译器, 使用 Action State, 上下文, 或前置Ref.

9 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

用于写作,审查,再造,或迁移的现代反应常规 反应:使纯度,"钩子"规则,"你可能不需要一个效果",状态放置, refs,上下文,悬浮数据获取,动作和形式状态,服务器和客户端组件,反应编译器,按角色进行测试. 以“核心类型”和“建筑设计”为基础。 当用户提及 React, hook, use Effect, use State, re-resters, 服务器组件, "使用客户端", Suspense, React 编译器, 使用 Action State, 上下文, 或前置Ref.

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:React Conventions — Framework Skill、How to Use This Skill、Output Format、Rules for Every Mode、Ruleset、purity → `references/purity.md`。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/worked-example.md、references/purity.md、references/hooks.md、references/state.md、references/effects.md、references/refs.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Modern React conventions for writing, reviewing, refactoring, or migrating React: render purity, the Rules of Hooks, "you might not need an Effect", state placement, refs, context, Suspense data fetching, Actions and form state, Server and Client Components, the React Compiler, testing by role. Builds on `core-typescript` and `architecture-and-design`. Use it when the user mentions React, hooks, useEffect, useState, re-renders, Server Components, "use client", Suspense, the React Compiler, useActionState, context, or forwardRef.

React Conventions — Framework SkillHow to Use This SkillOutput FormatRules for Every ModeRulesetpurity → `references/purity.md`hooks → `references/hooks.md`state → `references/state.md`effects → `references/effects.md`refs → `references/refs.md`context → `references/context.md`data-fetching → `references/data-fetching.md`

· 许可:CC-BY-4.0

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
react
description
Modern React conventions for writing, reviewing, refactoring, or migrating React: render purity, the Rules of Hooks, "you might not need an Effect", state placement, refs, context, Suspense data fetching, Actions and form state, Server and Client Components, the React Compiler, testing by role. Builds on `core-typescript` and `architecture-and-design`. Use it when the user mentions React, hooks, useEffect, useState, re-renders, Server Components, "use client", Suspense, the React Compiler, useActionState, context, or forwardRef.
许可
CC-BY-4.0
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 12
  • references/worked-example.md
  • references/purity.md
  • references/hooks.md
  • references/state.md
  • references/effects.md
  • references/refs.md
  • references/context.md
  • references/data-fetching.md
  • references/forms.md
  • references/server-client.md
  • references/rendering.md
  • references/testing.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「react」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-dddf6d7467080972-%E5%8F%8D%E5%BA%94.html
请存为 .cursor/skills/react/SKILL.md 或 .claude/skills/react/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/danielteles/awesome-agent-skills 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/danielteles/awesome-agent-skills' --list

npx skills add 'https://github.com/danielteles/awesome-agent-skills' --skill 'react'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: react description: >- Modern React conventions for writing, reviewing, refactoring, or migrating React: render purity, the Rules of Hooks, "you might not need an Effect", state placement, refs, context, Suspense data fetching, Actions and form state, Server and Client Components, the React Compiler, testing by role. Builds on `core-typescript` and `architecture-and-design`. Use it when the user mentions React, hooks, useEffect, useState, re-renders, Server Components, "use client", Suspense, the React Compiler, useActionState, context, or forwardRef. license: CC-BY-4.0 metadata: author: danielteles version: "1.0" --- # React Conventions — Framework Skill React-specific rules for modern React: function components, hooks, Server Components, Actions, the React Compiler. It gives the React form of rules that `core-typescript` and `architecture-and-design` set in general terms. > **Builds on.** `core-typescript` (language rules) and `architecture-and-design` (design). Load a > sibling only when the task turns on its layer; if it is not loaded, apply that layer from > general knowledge and do not block. This SKILL.md is self-sufficient: the **Ruleset** below is the complete, enforceable list. Each `references/.md` holds that group's reasoning and `❌ / ✅` code, and `references/worked-example.md` a full review pass; open them for depth when your runtime allows. --- ## How to Use This Skill Pick the mode that matches the task. Do the steps in order. | Mode | Steps | |---|---| | **Generate** — write a new component or hook | 1. Keep render pure; type the props (`purity`). 2. Before you write a `useEffect`, check `effects` — most do not need one. 3. Derive state during render; reset with `key` (`state`). 4. Run the Ruleset as a checklist. Fix each fail before you hand off. | | **Review** — check a pull request or a diff | 1. Run the Ruleset against the diff. 2. Write one finding per fail, in the Output Format below. 3. Order the findings: `must-fix` first, then `consider`. 4. If nothing fails, say so in one line. Do not invent findings. | | **Migrate** — modernize legacy React | 1. Run the React 19 types codemod, then the `forwardRef` and `` codemods. 2. Turn on `eslint-plugin-react-hooks` (v6 or later, `recommended`) and fix every warning. 3. Adopt the React Compiler; then delete hand-written `useMemo` / `useCallback` that only guarded referential identity. 4. One change kind per commit. Keep the tests green. | ### Output Format Write one finding per line: ``` · · : — . . ``` - `` is `must-fix` (breaks a rule in this skill or a lint rule) or `consider` (safe, but a rule prefers another form). - `` is a Ruleset topic slug (`effects`, `state`, `data-fetching`, …). ### Rules for Every Mode - Name the Ruleset topic when you enforce a rule. - Prefer the current API over its predecessor: `ref` as a prop over `forwardRef`, `` over ``, an Action over a manual submit `useEffect`. - Before you reach for `useEffect`, ask why the code runs. If the answer is not "because the component is on screen and must sync with an external system", it does not belong in an Effect. --- ## Ruleset ### purity → `references/purity.md` - [ ] Render is pure: no mutation of props, state, or a prior render's value; no side effect in the render body; the app tree is wrapped in ``. - [ ] Same props, state, and context produce the same JSX. - [ ] Props are a `type` or `interface`, not `React.FC`; children typed as `ReactNode`; event handlers typed with their React event type. - [ ] `ref` is accepted as a plain prop — no `forwardRef` on a new component. - [ ] One component per file, file name matching the component; no `import React` just for JSX (`"jsx": "react-jsx"`). - [ ] `useId()` supplies a label / `aria-*` id, never a list key; element choice and accessible names follow `accessibility`. - [ ] `eslint-plugin-react` and `eslint-plugin-react-hooks` (v6+, `recommended`) are on and every warning fixed, not disabled. ### hooks → `references/hooks.md` - [ ] Every hook is called at the top level of a component or another hook, before any early `return` — never in a condition, loop, nested function, event handler, `try`/`catch`, or a function passed to `useMemo` / `useReducer` / `useEffect`. - [ ] Hooks are called only from a function component or a custom hook. - [ ] Shared stateful logic is a custom hook named `useX` returning a stable, typed value. - [ ] `useEffect` / `useMemo` / `useCallback` dependency arrays are complete and not suppressed. ### state → `references/state.md` - [ ] State is colocated in the component that uses it; lifted only when a second component needs the same value. - [ ] A value derivable from props or other state is computed during render, not copied into state. - [ ] No prop is mirrored into state; a subtree resets via `key`, not by clearing fields in an Effect. - [ ] State is never mutated in place — a new value is built and set. - [ ] The updater form (`setX(x => …)`) is used when the next value depends on the previous. - [ ] An expensive initial value uses the lazy form `useState(() => build())`. - [ ] `useReducer` when several fields change together or the next state depends on an event plus current state. - [ ] An external store is read with `useSyncExternalStore`, not `useState` + a subscribe Effect. ### effects → `references/effects.md` - [ ] No Effect for: transforming data for render, an expensive calc (`useMemo`), resetting state on a prop change (`key`), a user event, a POST, a chain of state updates, notifying the parent, or one-time app init. - [ ] An Effect exists only to synchronize with an external system (widget, socket, subscription, document title). - [ ] Every Effect has a cleanup that undoes its setup; one Effect per synchronization. - [ ] An Effect that fetches guards against a stale response (`AbortController` / ignore flag) — or, better, uses a cache library (see `data-fetching`). - [ ] A reusable Effect is extracted into a custom hook. - [ ] Reading the latest value without re-subscribing uses an Effect Event (`useEffectEvent`), not a dishonest dependency array. ### refs → `references/refs.md` - [ ] `useRef` only for values that must survive renders without triggering one (DOM node, timer id, previous value). - [ ] No `ref.current` read or write during render — only in an event handler or an Effect. - [ ] `ref` is a plain prop; no `forwardRef`. - [ ] An imperative API is exposed with `useImperativeHandle` and is small and named (`focus`, `scrollIntoView`). - [ ] A `ref` callback that attaches a listener returns a cleanup function that detaches it. - [ ] Focus is moved with a ref after navigation, after an async action, and when a dialog opens. - [ ] The ref is an escape hatch — state or a prop is tried first. ### context → `references/context.md` - [ ] Context holds only low-frequency, widely-read data (theme, locale, current user, DI container). - [ ] A fast-changing value is in its own context, or in local state / a store with selectors — not a wide context. - [ ] The provider is `` (React 19), not ``. - [ ] Context is read with `useContext`; `use(Context)` only where the read must be conditional. - [ ] The context `value` is memoized (or the React Compiler is on) — never an inline object literal. ### data-fetching → `references/data-fetching.md` - [ ] No bare `useEffect` fetch: a framework loader, a cache library (TanStack Query, SWR), or `use(promise)` with a cache-created promise. - [ ] Each request has a stable cache key derived from its inputs. - [ ] An async read is wrapped in `` with a real fallback and an error boundary around each independent region. - [ ] A render error is caught by a class boundary or `react-error-boundary` — there is no hook. - [ ] A non-urgent update uses `useTransition` / `useDeferredValue`. - [ ] A mutation updates the cache from the response; `useOptimistic` only with a rollback path. ### forms → `references/forms.md` - [ ] Submit is `` driven by `useActionState`; child pending state via `useFormStatus`. - [ ] An optimistic row uses `useOptimistic` (which reverts on failure), not hand-rolled optimistic state. - [ ] An input is never switched between controlled and uncontrolled mid-life; which mode a field defaults to is `component-api-design`, controlled-uncontrolled. - [ ] Validators are built from the same schema the server uses, and the server re-validates. - [ ] Entered values survive a failed submit; each field error maps back to its field. ### server-client → `references/server-client.md` - [ ] Components are Server Components by default (no directive); no state, Effects, browser APIs, or handlers in them. - [ ] A Server Component that needs data is `async` and `await`s it in render (reads the database or a file directly) — no client round-trip built for its own data. - [ ] `'use client'` sits on the smallest interactive leaf, not a page or layout. - [ ] A server function is marked `'use server'` and called as an Action; props across the boundary are serializable (no functions except Server Actions, no class instances). - [ ] No server-only module (db client, secret, `fs`) is reachable from a `'use client'` file; `server-only` enforces it. - [ ] Data fetching happens in the Server Component or loader, and the result is passed down. ### rendering → `references/rendering.md` - [ ] The React Compiler is on; where it is not, `memo` / `useMemo` / `useCallback` appear only on a path measured with the Profiler. - [ ] No fresh object / array / function built in render and passed to a memoized child. - [ ] `key` is a stable id from the data, never the array index (`architecture-and-design`, frontend-practices). - [ ] Routes are code-split with `lazy()` + ``; a list beyond a few hundred rows is virtualized. - [ ] `

相关技能

设计创意

Automation Workflows

设计和实施自动化工作流程,以节省时间和规模化操作作为独家. 用于识别重复任务实现自动化,构建跨工具的工作流程,设置触发器和行动,或优化现有自动化. 包括自动化机会识别,工作流程设计,工具选择(Zapier,Make,n8n),测试,和维护. 触发"自动","自动","工作流程自动…

设计创意

Ui Ux Pro Max

UI/UX设计智能及建筑抛光接口实施指导. 当用户要求UI设计,UX流量,信息架构,视觉风格方向,设计系统/托盘,组件规格,副本/显微镜,可访问性,或生成/critique/refine前端UI(HTML/CSS/JS,React,Next.js,Vue,Svelte,Tailw…

设计创意

Frontend Design

创建美丽现代UI的专家前端设计指南. 在构建起落架页面,仪表板,或任何用户界面时使用.

设计创意

N8n Workflow Automation

设计和输出 n8n 工作流程 JSON 有强力触发器, idempotency, 错误处理, 记录, 重试, 以及 人入"一站"审查队列. 当您需要可审计的自动化时使用.