Skip to content
Skillpedia
Websites & UI (frontend)40k · #5329

react18-legacy-context

Provides the complete pattern for migrating React's legacy context to the modern API. It helps update context providers and consumers.

What it does

This tool helps update old React code to use a newer system called 'createContext'. It guides you through replacing outdated parts of the code that handle data sharing between components.

When to use it

  • ✓When you see warnings about 'contextTypes' or 'getChildContext' in your React code.
  • ✓When updating a React application to newer versions (React 18 or higher).
  • ✓Before modifying any code related to old React component data sharing.

Example of what to ask your AI

“How do I update React's old context system to the new 'createContext'?”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/github/awesome-copilot/blob/main/skills/react18-legacy-context/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/react18-legacy-context/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool identifies where data is shared (providers) and where it's used (consumers). It then provides a step-by-step plan to create a new context file and update both providers and all consumers to use the new API.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

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

Or download just the file:

curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/react18-legacy-context/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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

# 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
FAQ

What are 'contextTypes', 'childContextTypes', and 'getChildContext'?

These are old ways in React to share data between components. They have been replaced by a more modern and flexible approach called 'createContext'.

Why do I need to update all consumers?

If you don't update every place that uses the old data, your application might stop working correctly or show incorrect information.

What are a 'provider' and a 'consumer'?

The 'provider' is the component that supplies the data. 'Consumers' are the components that receive and use that data.

Details

Original description by the author

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, becaus

repo: github/awesome-copilot

Popularity

GitHub stars
40k
Ranking position
#5329
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills