react18-legacy-context — скилл для Copilot
Скилл переводит legacy context в React на createContext и помогает синхронно обновить provider и всех consumers. Нужен для миграции class components.
npx skills add github/awesome-copilot --skill react18-legacy-contextЧто делает react18-legacy-context
Скилл описывает миграцию legacy context API с contextTypes, childContextTypes и getChildContext на современный createContext. Он требует работы с несколькими файлами: сначала находится provider, затем все consumers, после чего создаётся модуль контекста и обновляются связанные компоненты.
Внутри есть порядок миграции, команды для поиска provider, consumers и обращений к this.context, а также ссылки на примеры для одного и нескольких контекстов и шаблон файла контекста. Class components переводятся на contextType, function components — на useContext. Legacy context удалён в React 19, а в React 18.3.1 он выдаёт предупреждения.
Ставьте скилл перед такой миграцией, если нужно согласовать provider и consumers. Для небольшого изменения без legacy context он не нужен.
Какие задачи решает
- найти provider с
childContextTypesиgetChildContext - обнаружить всех consumers с
contextTypes - перевести class components на
contextType - заменить legacy context в function components на
useContext - проверить приложение после миграции
Примеры запросов агенту
- Найди provider и всех consumers legacy context в `src/`, затем составь план миграции.
- Создай файл контекста и переведи этот class component с `contextTypes` на `contextType`.
- Проверь проект на оставшиеся `childContextTypes`, `getChildContext` и предупреждения legacy context.
Как установить react18-legacy-context
1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill react18-legacy-context2GitHub CLI
gh skill install github/awesome-copilot react18-legacy-context3Вручную: положить файлы
.github/skills/react18-legacy-context/SKILL.md1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill react18-legacy-context -a claude-code2Вручную: положить файлы
~/.claude/skills/react18-legacy-context/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/react18-legacy-context/
Вручную: положить файлы
.agents/skills/react18-legacy-context/SKILL.mdДля всех проектов — ~/.agents/skills/
Вручную: положить файлы
.cursor/skills/react18-legacy-context/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
Командой платформы
gemini skills install https://github.com/github/awesome-copilot --path skills/react18-legacy-contextВручную: положить файлы
.devin/skills/react18-legacy-context/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Из того же набора554
Весь набор →Похожие
Вопросы о react18-legacy-context
Как установить react18-legacy-context в GitHub Copilot?
Выполните npx skills add github/awesome-copilot --skill react18-legacy-context или gh skill install github/awesome-copilot react18-legacy-context. Файл скилла находится по пути .github/skills/react18-legacy-context/SKILL.md.
Что делает react18-legacy-context?
Он помогает перенести legacy context API с contextTypes, childContextTypes и getChildContext на createContext. Provider и все consumers обновляются согласованно.
Почему миграцию нужно делать сразу в нескольких файлах?
Provider и consumers используют связанный контракт контекста. Если обновить только одну сторону, приложение может читать неправильный context или получить undefined.
Исходный текст
SKILL.md · MIT
--- name: react18-legacy-context description: '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, because migrating only the provider without the consumers (or vice versa) will cause a runtime failure. Always read this skill before writing any context migration - the cross-file coordination steps here prevent the most common context migration bugs.' --- # 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: 1. Create the context object (usually a new file) 2. Update the **provider** component 3. 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 ```bash # 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 consumer - **`references/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
© github · MIT · github/awesome-copilot