github avatar

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-code

Installs 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:

  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

# 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
1mindrally avatarshopifymindrally/skillsExpert Shopify theme development guidelines for Liquid, Online Store 2.0, CSS, JavaScript, and UX best practices743skills.sh installs
2netresearch avatargit-workflownetresearch/git-workflow-skillUse when establishing branching strategies, implementing Conventional Commits, creating or reviewing PRs, resolving PR review comments, merging PRs (including C743skills.sh installs
3ruvnet avatarintelligence-routeruvnet/rufloRoute tasks via the 3-tier model selector and learned patterns; emits a routing rationale via hooks_explain743skills.sh installs
4alchaincyf avatarhuashu-wechat-imagealchaincyf/huashu-skills为微信公众号文章生成高质量配图。支持封面图(2.35:1)、正文插图(16:9/4:3)、信息图。提供两条路径:AI生成(视觉创意型)和HTML渲染(文字精确型)。当用户提到"公众号配图"、"公众号封面"、"文章配图"、"正文插图"、"公众号图片"时使用此技能。740skills.sh installs
5alchaincyf avatarhuashu-xhs-imagealchaincyf/huashu-skills为小红书笔记生成高质量配图。默认AI生成(Gemini),仅精确数据表格用HTML兜底。当用户提到"小红书配图"、"小红书封面"、"小红书图片"、"做张小红书图"、"笔记配图"时使用此技能。740skills.sh installs
6ruvnet avatarddd-contextruvnet/rufloCreate and manage a DDD bounded context with standard directory structure. Use when starting a new subdomain, splitting a monolith into bounded contexts, or sca739skills.sh installs