
React 18 Legacy Context Migration
OfficialFreeSimplify migration from legacy context to createContext.
Free · Opens the source repo
What React 18 Legacy Context Migration does
The React 18 Legacy Context Migration skill provides a structured approach to transition from the deprecated legacy context API to the modern createContext API in React applications. This skill is particularly useful for developers working with class components that still utilize contextTypes, childContextTypes, and getChildContext, which were deprecated in React 16.3 and removed in React 19. By following the outlined steps, developers can ensure a smooth migration process that minimizes the risk of runtime errors.
Migrating context in React is not a straightforward task, as it requires careful coordination across multiple files. The skill emphasizes the importance of updating both the provider and all consumer components together. Failing to update all consumers can lead to broken applications, where the context may read from the wrong source or result in undefined values. This skill provides a clear migration pattern that includes scanning commands to identify existing providers and consumers, ensuring that nothing is overlooked during the migration.
Included in the skill are reference files that offer complete migration examples for single and multiple contexts, as well as a template for creating new context modules. These resources serve as practical guides for developers, helping them to implement the migration effectively and verify that no legacy context warnings persist after the changes are made. This skill is essential for any team looking to modernize their React codebase while maintaining stability and functionality.
When to use it
Use this skill when you need to migrate legacy context APIs in class components to the modern createContext API, especially in larger applications with multiple context usages.
When not to use it
This skill is not suitable for applications that do not use the legacy context API or for those already using function components with hooks.
What you can build with it
Migrating a Single Context
Use this skill to migrate a single legacy context, ensuring all components are updated accordingly.
Updating Multiple Contexts
Handle the migration of multiple legacy contexts in a single application, coordinating updates across different components.
Preparing for React 19
Get your application ready for React 19 by migrating all legacy context usages to avoid runtime issues.
How to install React 18 Legacy Context Migration
View source1. Install with the skills CLI
npx skills add github/awesome-copilot/react18-legacy-context --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by githubReact 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
Frequently asked questions about React 18 Legacy Context Migration
Similar skills
React Composition Patterns
Streamline your React component architecture with proven patterns.
Pester Should Migration
Easily convert Pester v5 assertions to v6 syntax.
Radix to Base UI Migration
Seamlessly migrate React components from Radix UI to Base UI.
Migrate Next.js to Vinext
Seamlessly transition your Next.js projects to Vinext.
WinUI 3 Migration Guide
Streamline your UWP to WinUI 3 migration process.
Refactor
Enhance code maintainability without altering behavior.
