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

/react18-string-refs

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

Provides exact migration patterns for React string refs (ref="name" + this.refs.name) to React.createRef() in class components. Use this skill whenever migrating string ref usage - including single element refs, multiple refs in a component, refs in lists, callback refs, and refs passed to child components. Always use this skill before writing any ref migration code - the multiple-refs-in-list pattern is particularly tricky and this skill prevents the most common mistakes. Use it for React 18.3.1 migration (string refs warn) and React 19 migration (string refs removed).

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/react18-string-refs

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

SKILL.md

≈149 tokens for metadata: the name and description. ≈373 when used: this file. ≈1.7k more on demand in 1 file.

Description uses 7.5% 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 ≈598 characters, or 7.5%.

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 String Refs Migration

String refs (ref="myInput" + this.refs.myInput) were deprecated in React 16.3, warn in React 18.3.1, and are removed in React 19.

Quick Pattern Map

Pattern Reference
Single ref on a DOM element → patterns.md#single-ref
Multiple refs in one component → patterns.md#multiple-refs
Refs in a list / dynamic refs → patterns.md#list-refs
Callback refs (alternative approach) → patterns.md#callback-refs
Ref passed to a child component → patterns.md#forwarded-refs

Scan Command

# Find all string ref assignments in JSX
grep -rn 'ref="' src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."

# Find all this.refs accessors
grep -rn "this\.refs\." src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."

Both should be migrated together - find the ref="name" and the this.refs.name accesses for each component as a pair.

The Migration Rule

Every string ref migrates to React.createRef():

  1. Add refName = React.createRef(); as a class field (or in constructor)
  2. Replace ref="refName" → ref={this.refName} in JSX
  3. Replace this.refs.refName → this.refName.current everywhere

Read references/patterns.md for the full before/after for each case.

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 collection of migration guides and code patterns for updating React string refs. It contains no malicious code, suspicious URLs, or dangerous commands.

  • 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-string-refs

Provides exact migration patterns for converting React string refs (ref="name" + this.refs.name) to React.createRef() in class components. Covers single refs, multiple refs, list refs, callback refs, and forwarded refs — use before any React 18.3.1+ or React 19 migration that removes or warns on string ref syntax.

Generated from the current SKILL.md.

Does this skill cover React 19 migration?
Yes. String refs are removed entirely in React 19, so this skill applies to both React 18.3.1 (where they warn) and React 19 migrations.
What's the basic migration pattern?
Replace `ref="name"` with `ref={this.refName}`, add a class field `refName = React.createRef()`, and change `this.refs.name` to `this.refName.current`.
Does this cover refs in lists and dynamic refs?
Yes. The skill includes specific patterns for refs in lists, which it flags as particularly tricky and a common source of mistakes.
Does this apply to functional components?
No. String refs only work in class components, so this skill targets class component migrations exclusively.
Does this cover callback refs?
Yes, callback refs are included as an alternative approach alongside React.createRef patterns.

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