MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

React18-Legacy-Context

React18-Legacy-Context is an code AI skill with a core value of Provides the complete migration pattern for React legacy context API (contextTypes, childContextTypes, getChildContext) to the modern createContext API. It helps developers solve real-world problems in the code domain, boosting efficiency, automating repetitive tasks, and optimizing workflows.

Provides the complete migration pattern for React legacy context API (contextTypes, childContextTypes, getChildContext) to the modern createContext API. Use this skill whenever migrating legacy contex

Last verified on: 2026-07-14

Quick Facts

Category code
Works With Claude, GitHub Copilot
Source github/awesome-copilot
Stars ⭐ 34.1k
Last Verified 2026-07-14
Risk Level Low
mkdir -p ./skills/react18-legacy-context && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/react18-legacy-context/SKILL.md -o ./skills/react18-legacy-context/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

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


text
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


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

🎯 Best For

  • Claude users
  • GitHub Copilot users
  • Software engineers
  • Development teams
  • Tech leads

💡 Use Cases

  • React component optimization
  • Hook dependency audits

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply React18-Legacy-Context to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Is React18-Legacy-Context compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for React18-Legacy-Context?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install React18-Legacy-Context?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/react18-legacy-context/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills