Skip to main content
skill GitHub Copilot official · GitHub

react18-legacy-context — GitHub Copilot skill

This skill migrates React legacy context to createContext and coordinates the provider with every consumer. Use it for class component context migrations.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill react18-legacy-context
Open on GitHub

What react18-legacy-context does

The skill covers migration from the legacy context API built around contextTypes, childContextTypes, and getChildContext to createContext. It treats the work as a cross-file change: find the provider, locate every consumer, create the context module, then update both sides.

It includes the migration order, search commands for providers, consumers, and this.context usage, plus references for single-context and multi-context projects. Class components move to contextType; function components use useContext. Legacy context was removed in React 19 and produces warnings in React 18.3.1.

Install it before changing legacy context code when provider and consumer coordination matters. Skip it for projects that do not use the legacy API.

What it helps with

  • find providers using childContextTypes and getChildContext
  • locate every consumer that defines contextTypes
  • move class components to contextType
  • replace legacy context in function components with useContext
  • check the app after the migration

Example prompts for the agent

  • Find the legacy context provider and every consumer under `src/`, then plan the migration.
  • Create the context module and update this class component from `contextTypes` to `contextType`.
  • Scan the project for remaining `childContextTypes`, `getChildContext`, and legacy context warnings.

How to install react18-legacy-context

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill react18-legacy-context

2GitHub CLI

gh skill install github/awesome-copilot react18-legacy-context

3Manually: put the files in place

.github/skills/react18-legacy-context/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

Questions about react18-legacy-context

How do I install react18-legacy-context in GitHub Copilot?

Run npx skills add github/awesome-copilot --skill react18-legacy-context or gh skill install github/awesome-copilot react18-legacy-context. The skill file is at .github/skills/react18-legacy-context/SKILL.md.

What does react18-legacy-context do?

It guides migration from contextTypes, childContextTypes, and getChildContext to createContext. The provider and all consumers are updated as one migration.

Why does this React migration require multiple files?

The provider and consumers share the context contract. Updating only one side can make the app read the wrong context or receive undefined.

Source text

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

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor