New advertisers: 50% off your first month with code FIRSTMONTHSee slots
github avatar

React18 String Refs

Migration guide for React string refs to React.createRef() in class components, covering React 18.3.1 and React 19.

skills.sh installs
744
GitHub stars
41.4K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers single refs, multiple refs, list and dynamic refs, callback refs, and refs forwarded to child components
  • Includes grep scans for ref=" and this.refs. in src/ and a per-case before/after reference in references/patterns.md
  • Enforces a three-step rewrite: add a React.createRef() class field, switch JSX to ref={this.name}, and replace this.refs.name with this.name.current
  • Designed for teams preparing class components for React 19, where string refs are removed

Install

$ npx -y skills add github/awesome-copilot --skill react18-string-refs -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

PatternReference
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

Details

Repository
github.com/github/awesome-copilot
Categories
Frontend & UI Code, Code Review & Quality
First seen
May 16, 2026

More from github/awesome-copilot

All 293

Similar to React18 String Refs

More Frontend & UI Code