
React18 Legacy Context
If you're staring down legacy React context code with contextTypes and getChildContext, this walks you through the full migration to createContext without breaking your app in the process. The key insight here is that context migration is inherently cross-file work: you can't just update the provider or just update the consumers, you have to coordinate both or everything breaks at runtime. It gives you the exact grep commands to find all providers and consumers, then a strict ordering of steps to prevent the most common mistake (missing a consumer somewhere). Includes reference files for single context, multiple contexts, and a template for the new context module structure.
- skills.sh installs
- 747
- GitHub stars
- 41K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add github/awesome-copilot --skill react18-legacy-context --agent claude-codeInstalls into .claude/skills of the current project.
Files
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\."
Sponsors
Details
- Repository
- github.com/github/awesome-copilot
- Categories
- Frontend Development, Backend & APIs, Git & Pull Requests, Documentation, AI & Agent Building
- First seen
- May 16, 2026
More from github/awesome-copilot
All 318- From The Other Side Vega746
- React18 Lifecycle Patterns745
- React18 String Refs743
- React18 Enzyme To Rtl742
- Code Tour739
- Linkedin Post Formatter361
- Ui Screenshots212
- Data Breach Blast Radius110
- Sql Server Table Reconciliation104
- Aws Cloudwatch Investigation
- Aws Cost Optimize
- Aws Resource Health Diagnose
- Aws Well Architected Review
- Azure Well Architected Review
- Bug Reproduction Brief
- Incident Postmortem
- Mcp Implementation Security Review
- Pester Migration
- Tm7 Threat Model
- Git Commit48.4K
- Excalidraw Diagram Generator34.4K
- Multi Stage Dockerfile31.5K
- Documentation Writer28.4K
- Prd24.4K