react18-string-refs — GitHub Copilot skill: migration guide
Guides the move from string refs to React.createRef() in class components. Use it when preparing a project for React 18.3.1 or React 19.
npx skills add github/awesome-copilot --skill react18-string-refsWhat react18-string-refs does
The skill maps ref="name" to ref={this.name} and this.refs.name to this.name.current. Its patterns cover single and multiple refs, refs in lists, callback refs, and refs passed to child components.
It includes shell commands to find string refs under src/ and a pattern map pointing to migration examples. Search for JSX assignments and this.refs accessors together so each pair can be migrated. React 18.3.1 warns about string refs; React 19 removes them.
Install it when updating class components that use string refs. The list-ref guidance is especially relevant when refs are created dynamically.
What it helps with
- find string refs in JSX files
- replace
this.refs.namewiththis.name.current - migrate several refs in one component
- handle refs in a dynamic list
- pass a ref to a child component
Example prompts for the agent
- Find string refs under `src/` and outline the migration.
- Migrate `ref="input"` and `this.refs.input` to `React.createRef()` in this class component.
- Update the refs in this list using the skill's pattern.
How to install react18-string-refs
1Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill react18-string-refs2GitHub CLI
gh skill install github/awesome-copilot react18-string-refs3Manually: put the files in place
.github/skills/react18-string-refs/SKILL.md1Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill react18-string-refs -a claude-code2Manually: put the files in place
~/.claude/skills/react18-string-refs/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/react18-string-refs/
Manually: put the files in place
.agents/skills/react18-string-refs/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/react18-string-refs/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
Platform CLI
gemini skills install https://github.com/github/awesome-copilot --path skills/react18-string-refsManually: put the files in place
.devin/skills/react18-string-refs/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set554
The whole set →Similar
Questions about react18-string-refs
How do I install react18-string-refs for GitHub Copilot?
Run npx skills add github/awesome-copilot --skill react18-string-refs. You can also use gh skill install github/awesome-copilot react18-string-refs.
What does react18-string-refs do?
It guides migration from string refs to React.createRef() in class components. It covers refs on single elements, lists, callbacks, and child components.
What changes when migrating a string ref?
Replace ref="refName" with ref={this.refName}, then change this.refs.refName to this.refName.current. The skill also provides commands to find both patterns under src/.
Source text
SKILL.md · MIT
---
name: react18-string-refs
description: '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).'
---
# 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](references/patterns.md#single-ref) |
| Multiple refs in one component | [→ patterns.md#multiple-refs](references/patterns.md#multiple-refs) |
| Refs in a list / dynamic refs | [→ patterns.md#list-refs](references/patterns.md#list-refs) |
| Callback refs (alternative approach) | [→ patterns.md#callback-refs](references/patterns.md#callback-refs) |
| Ref passed to a child component | [→ patterns.md#forwarded-refs](references/patterns.md#forwarded-refs) |
## Scan Command
```bash
# 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.
© github · MIT · github/awesome-copilot