Index of every page on this site: llms.txt
All skills
github avatar

/react18-legacy-context

@f10fdb8 official
by githubgithub/awesome-copilot42k stars
5,426
Run it yourself

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, because migrating only the provider without the consumers (or vice versa) will cause a runtime failure. Always read this skill before writing any context migration - the cross-file coordination steps here prevent the most common context migration bugs.

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/react18-legacy-context

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈168 tokens for metadata: the name and description. ≈446 when used: this file. ≈3.6k more on demand in 3 files.

Description uses 8.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈671 characters, or 8.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

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

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo4 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill is a developer-focused migration guide for React applications. It provides instructions, templates, and static analysis commands to help developers move from legacy context APIs to modern React patterns. No security risks were identified.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f10fdb8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 7 months ago

README badge

README badge for github/awesome-copilot/react18-legacy-context

Provides the step-by-step migration pattern for converting React legacy context (contextTypes, childContextTypes, getChildContext) to createContext, with emphasis on coordinating provider and consumer updates across multiple files. Targets React 18.3.1+ codebases migrating before React 19 removal, and prevents the common bug of updating only the provider or only consumers without the other.

Generated from the current SKILL.md.

Does this skill handle both class and function components?
Yes. Class components migrate to contextType, function components migrate to useContext. The skill provides patterns for both in the reference files.
What happens if I migrate only the provider without updating all consumers?
The app will break at runtime. Consumers will read from the wrong context or get undefined. This skill emphasizes that context migration is always cross-file and requires updating the provider AND every consumer together.
Does this work with React 19?
This skill is necessary for React 19 because legacy context (contextTypes, childContextTypes, getChildContext) was removed in that version.
How do I find all the places that need to be updated?
The skill includes grep commands to scan for providers (childContextTypes/getChildContext), consumers (contextTypes), and this.context usage across your codebase.
Does this skill handle multiple contexts in the same app?
Yes. The references include a multi-context pattern for apps with nested providers and multiple legacy contexts.

Generated from the current SKILL.md. These answers refresh after source changes.