react18-legacy-context
できること
このツールは、古いReactコードを「createContext」という新しい仕組みを使うように更新する手助けをします。コンポーネント同士でデータを共有する部分のうち、古くなった箇所を置き換える手順を案内します。
使う場面
- ✓Reactのコードに「contextTypes」や「getChildContext」に関する警告が表示されたとき。
- ✓Reactアプリケーションを新しいバージョン(React 18以上)に更新するとき。
- ✓古いコンポーネント間のデータ共有に関わるコードを変更する前。
スキルのリンク
https://github.com/github/awesome-copilot/blob/main/skills/react18-legacy-context/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Reactの古いコンテキストの仕組みを、新しい「createContext」に更新するにはどうすればよいですか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは、データを提供している場所(プロバイダー)と、それを使っている場所(コンシューマー)を特定します。そのうえで、新しいコンテキストファイルを作成し、プロバイダーとすべてのコンシューマーを新しいAPIを使うように更新するための手順を段階的に示します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
React 18 Legacy Context Migration
Legacy context (contextTypes, childContextTypes, getChildContext) was deprecated in React 16.3 and warns in React 18.3.1. It is removed in React 19.
This Is Always a Cross-File Migration
Unlike most other migrations that touch one file at a time, context migration requires coordinating:
- Create the context object (usually a new file)
- Update the provider component
- Update every consumer component
Missing any consumer leaves the app broken - it will read from the wrong context or get undefined.
Migration Steps (Always Follow This Order)
Step 1: Find the provider (childContextTypes + getChildContext)
Step 2: Find ALL consumers (contextTypes)
Step 3: Create the context file
Step 4: Update the provider
Step 5: Update each consumer (class components → contextType, function components → useContext)
Step 6: Verify - run the app, check no legacy context warnings remain
Scan Commands
# Find all providers
grep -rn "childContextTypes\|getChildContext" src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."
# Find all consumers
grep -rn "contextTypes\s*=" src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."
# Find this.context usage (may be legacy or modern - check which)
grep -rn "this\.context\." src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."
Reference Files
references/single-context.md- complete migration for one context (theme, auth, etc.) with provider + class consumer + function consumerreferences/multi-context.md- apps with multiple legacy contexts (nested providers, multiple consumers of different contexts)references/context-file-template.md- the standard file structure for a new context module
よくある質問
「contextTypes」「childContextTypes」「getChildContext」とは何ですか?
Reactでコンポーネント間のデータを共有する古い方法です。より現代的で柔軟な「createContext」という方法に置き換えられています。
なぜすべてのコンシューマーを更新する必要があるのですか?
古いデータを使っている箇所をすべて更新しないと、アプリケーションが正しく動作しなくなったり、誤った情報を表示したりする可能性があるためです。
プロバイダーとコンシューマーとは何ですか?
「プロバイダー」はデータを提供するコンポーネントです。「コンシューマー」はそのデータを受け取って使うコンポーネントです。
詳細
作者による元の説明
Provides the complete migration pattern for React legacy context API (contextTypes, childContextTypes, getChildContext) to the modern createContext API. Use this skill whenever migrating legacy context in class components - this is always a cross-file migration requiring the provider AND all consumers to be updated together. Use it before touching any contextTypes or childContextTypes code, becaus
repo: github/awesome-copilot
人気
- GitHubのスター
- 40k
- ランキング
- #7386
- ライセンス
- MIT
- 更新日
- 2026/10/15
コメント
- …
このリポジトリの他のスキル
acquire-codebase-knowledge
40kエージェントが、既存のコードプロジェクトを理解してドキュメント化できるよう支援します。新しく参加するメンバーのオンボーディングや、アーキテクチャの全体像の把握に役立ちます。
acreadiness-assess
40kエージェントが、プロジェクトのAI対応状況を評価してレポートを生成できるよう支援します。プロジェクトがAIツールをどの程度活用できる状態にあるかを把握するのに役立ちます。
acreadiness-generate-instructions
40kエージェントが、評価結果をもとにAIツール向けの指示文を作成できるよう支援します。AIがコードとどのようにやり取りするかを改善し、特定された不足点を解消するのに役立ちます。
acreadiness-policy
40kエージェントが、AIプロジェクトの評価ポリシーの策定や適用を支援できるようにします。プロジェクトの評価方法を標準化し、コンプライアンスを確保するのに役立ちます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。