New advertisers: 50% off your first month with code FIRSTMONTHSee slots
github avatar

React18 Legacy Context

Migrates React legacy context (contextTypes, childContextTypes, getChildContext) to createContext across provider and consumers.

skills.sh installs
749
GitHub stars
41.4K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers provider and consumer updates for legacy context in React 18, which requires all files to change together
  • Includes a 6-step ordered workflow, three grep scan commands, and three reference files for single, multi-context, and new-module templates
  • Enforces provider-and-consumer updates together because migrating only one side causes runtime failures or undefined context reads
  • Designed for class and function component codebases on React 18.3.1 that must clear legacy context warnings before React 19

Install

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

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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\."

Details

Repository
github.com/github/awesome-copilot
Category
Frontend & UI Code
First seen
May 16, 2026

More from github/awesome-copilot

All 293

Similar to React18 Legacy Context

More Frontend & UI Code