react19-concurrent-patterns
它能做什么
这个工具可以帮你确认,把 React 代码升级到 19 版本之后,与 React 18 中已经存在的并发(concurrency)特性相关的代码仍然能正常工作。它也会建议你在什么时候采用 React 19 的新特性。
适用场景
- ✓当你要把 React 项目从较旧版本升级到 React 19 时。
- ✓当你需要检查与性能(并发)相关的重要代码在升级到 React 19 后是否仍然完好时。
- ✓在主要升级稳定之后,决定可以加入哪些 React 19 的新特性。
技能链接
https://github.com/github/awesome-copilot/blob/main/skills/react19-concurrent-patterns/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查在升级到 React 19 的过程中,用于过渡(`useTransition`)和延迟值(`useDeferredValue`)的代码是否保持完好。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会检查你代码中使用 `useTransition`、`useDeferredValue` 和 `Suspense`(用于加载屏幕的部分内容)的地方,确认它们没有被意外修改。它还会指出升级稳定之后,可以使用的 React 19 新特性。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
React 19 Concurrent Patterns
React 19 introduced new APIs that complement the migration work. This skill covers two concerns:
- Preserve existing React 18 concurrent patterns that must not be broken during migration
- Adopt new React 19 APIs worth introducing after migration stabilizes
Part 1 Preserve: React 18 Concurrent Patterns That Must Survive the Migration
These patterns exist in React 18 codebases and must not be accidentally removed or broken:
createRoot Already Migrated by the R18 Orchestra
If the R18 orchestra already ran, ReactDOM.render → createRoot is done. Verify it's correct:
// CORRECT React 19 root (same as React 18):
import { createRoot } from 'react-dom/client';
const root = createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
useTransition No Migration Needed
useTransition from React 18 works identically in React 19. Do not touch these patterns during migration:
// React 18 useTransition unchanged in React 19:
const [isPending, startTransition] = useTransition();
function handleClick() {
startTransition(() => {
setFilteredResults(computeExpensiveFilter(input));
});
}
useDeferredValue No Migration Needed
// React 18 useDeferredValue unchanged in React 19:
const deferredQuery = useDeferredValue(query);
Suspense for Code Splitting No Migration Needed
// React 18 Suspense with lazy unchanged in React 19:
const LazyComponent = React.lazy(() => import('./LazyComponent'));
function App() {
return (
<Suspense fallback={<Spinner />}>
<LazyComponent />
</Suspense>
);
}
Part 2 React 19 New APIs
These are worth adopting in a post-migration cleanup sprint. Do not introduce these DURING the migration stabilize first.
For full patterns on each new API, read:
references/react19-use.mdtheuse()hook for promises and contextreferences/react19-actions.mdActions, useActionState, useFormStatus, useOptimisticreferences/react19-suspense.mdSuspense for data fetching (the new pattern)
Migration Safety Rules
During the React 19 migration itself, these concurrent-mode patterns must be left completely untouched:
# Verify nothing touched these during migration:
grep -rn "useTransition\|useDeferredValue\|Suspense\|startTransition" \
src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."
If the migrator touched any of these files, review the changes the migration should only have modified React API surface (forwardRef, defaultProps, etc.), never concurrent mode logic.
常见问题
React 中的“并发”(concurrency)是什么?
并发是 React 同时管理多个任务的方式,能让用户界面更加灵敏,尤其是在后台有耗时操作的时候。
为什么在迁移过程中不应该使用 React 19 的新 API?
最好先确保主要升级顺利完成。如果同时引入新特性,一旦出现问题,排查起来会更加复杂。
这里的 `grep` 是做什么的?
`grep` 命令用于在你所有文件中搜索特定的代码片段(比如 `useTransition`)。这有助于确认在升级过程中,没有意外修改到重要的并发相关代码。
详情
作者的原始描述
Preserve React 18 concurrent patterns and adopt React 19 APIs (useTransition, useDeferredValue, Suspense, use(), useOptimistic, Actions) during migration.
repo: github/awesome-copilot
热度
- GitHub 星标
- 40k
- 排名
- #7389
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
acquire-codebase-knowledge
40k帮你的智能体理解并编写现有代码项目的文档。它有助于新成员快速上手,或者快速了解项目架构。
acreadiness-assess
40k让你的智能体评估一个项目对 AI 的准备程度,并生成报告。它有助于了解项目在使用 AI 工具方面的准备情况。
acreadiness-generate-instructions
40k帮你的智能体根据评估结果编写 AI 工具的指令文件。它有助于改善 AI 与代码的交互方式,并弥补已发现的不足。
acreadiness-policy
40k让你的智能体协助制定或应用 AI 项目评估的政策。它有助于规范项目的评估方式,并确保合规。