React 18 生命周期迁移

原名:react18-lifecycle-patterns

把类组件中的不安全生命周期方法迁移为 React 18 兼容实现。

中文 Skills 技能说明

适合处理 componentWillMount 等旧写法。先识别副作用和调用次数,再按组件逐个迁移并补测试;不能用简单改名掩盖时序问题。

上游能力依据

上游原始适用说明:Provides exact before/after migration patterns for the three unsafe class component lifecycle methods - componentWillMount, componentWillReceiveProps, and componentWillUpdate - targeting React 18.3.1. Use this skill whenever a class component needs its lifecycle methods migrated, when deciding between getDerivedStateFromProps vs componentDidUpdate, when adding getSnapshotBeforeUpdate, or when fixing React 18 UNSAFE lifecycle warnings. Always use this skill before writing any lifecycle migration code - do not guess the pattern from memory, the decision trees here prevent the most common migration mistakes.

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

使用边界

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

作者、翻译与许可证

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

适用范围

平台:linux、macos、windows;标签:设计与前端、React 18 生命周期迁移

安全提示

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

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