React 18 批处理模式

原名:react18-batching-patterns

诊断并修复 React 18 类组件自动批处理带来的状态更新差异。

中文 Skills 技能说明

适合升级后出现渲染次数或状态顺序问题。先用测试固定现象,再按最小范围调整 setState 和 flushSync;避免为了通过测试关闭框架优化。

上游能力依据

上游原始适用说明:Provides exact patterns for diagnosing and fixing automatic batching regressions in React 18 class components. Use this skill whenever a class component has multiple setState calls in an async method, inside setTimeout, inside a Promise .then() or .catch(), or in a native event handler. Use it before writing any flushSync call - the decision tree here prevents unnecessary flushSync overuse. Also use this skill when fixing test failures caused by intermediate state assertions that break after React 18 upgrade.

上游 SKILL.md 主要章节(保留原文标题):

使用边界

先核对上游说明、依赖、输入资料和所需权限。涉及写入、删除、发布、支付或外部发送时,必须在执行前人工确认。

作者、翻译与许可证

原作者
GitHub, Inc. 与 awesome-copilot contributors
中文翻译
CEOFans翻译
许可证
MIT
上游来源
https://github.com/github/awesome-copilot/tree/bbaa5872640e6cbae953beb22a71ae337398ca12/skills/react18-batching-patterns

适用范围

平台:linux、macos、windows;标签:设计与前端、React 18 批处理模式

安全提示

基础静态扫描不等于绝对安全。技能可能调用命令、浏览器、云服务或本地文件,请在最小权限环境中使用,高风险操作必须人工确认。

如发现侵权、许可证或安全问题,可在本页前台提交投诉,管理员复核后可立即下架。