/react18-upgrade:react18-string-refsfrom react18-upgrade
Migrates deprecated React string refs (ref="name", this.refs.name) to createRef(), callback refs, or forwardRef. Use when fixing React 18.3.1 warnings or preparing for React 19 removal of string refs.
Ships in react18-upgrade. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Convert deprecated React string refs into explicit refs by pairing every ref="name" assignment with its this.refs.name access, choosing the correct fixed, dynamic, callback, or child-component pattern, and producing a migration summary.
String refs use ref="myInput" or ref='myInput' in JSX and access the node through this.refs.myInput. They were deprecated in React 16.3, warn in React 18.3.1, and are removed in React 19.
Run both scans and migrate each pair together:
# 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\."
Also scan for single-quoted refs when the codebase uses them:
grep -rn "ref='" src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."
| Pattern | Use when | Required transformation |
|---|---|---|
| Single ref on a DOM element | One class component owns one fixed DOM node. | Add refName = React.createRef();, replace ref="refName" with ref={this.refName}, and replace this.refs.refName with this.refName.current. |
| Multiple refs in one component | A class has several fixed inputs, buttons, or containers. | Create one React.createRef() field per string ref; do not reuse a single ref object. |
| Refs in a list / dynamic refs | A map() or loop builds names such as ref={`tab_${i}`}. | Use a Map keyed by stable item IDs or a callback ref collection; avoid index-only keys when items can reorder. |
| Callback refs | The component needs attach/detach behavior or a dynamic collection. | Store the DOM node directly, not in .current; prefer a stable class field function over an inline callback. |
| Ref passed to a child component | The ref targets a custom component instead of a DOM element. | Update the child too: React 18 needs forwardRef; React 19 can receive ref as a direct prop. |
Read references/patterns.md when implementing the full before/after examples for single-ref, multiple-refs, list-refs, callback-refs, and forwarded-refs.
ref="name" with every this.refs.name usage before editing.refName = React.createRef(); as a class field, or initialize it in the constructor when the project does not use class fields.ref="refName" with ref={this.refName} in JSX.this.refs.refName with this.refName.current everywhere.this.refName.current?.focus() when the old code could run before mount or after unmount.tab.id, not by a transient index unless the list is truly static.this.tabRefs[i] is the element itself; do not append .current.references/patterns.md: complete before/after migrations for single DOM refs, multiple refs, dynamic list refs, callback refs, and child component refs.ref="name" without changing this.refs.name, or the reverse, leaves broken runtime access.ref={`tab_${i}`} needs a ref collection, not one tabRef field.this.inputEl?.focus() is correct; this.inputEl.current is not.<MyInput /> does not automatically point at the inner <input> unless the child forwards or accepts it.## React string ref migration
**Status:** migrated | planned | blocked
**Scope:** `<files or component>`
| Component | String refs found | Replacement pattern | Notes |
| --- | --- | --- | --- |
| `<Component>` | `ref="name"`, `this.refs.name` | `React.createRef()` | `<null checks, child changes, or list key>` |
**Validation**
- String ref scan: `<remaining hits or none>`
- `this.refs` scan: `<remaining hits or none>`
- Tests/build: `<command and result, or not run>`
ref="name" or ref='name' hit was paired with matching this.refs.name access before editing.React.createRef() fields or constructor assignments.Map, object, or callback collection keyed by a stable identity..current.forwardRef for React 18 or direct ref prop handling for React 19.references/patterns.md was consulted for any non-trivial pattern.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin react18-upgrade7 skills in this plugin
/react18-batching-patternsDiagnose and fix React 18 automatic batching regressions in class components. Use when multiple setState calls occur after await, inside setTimeout, Promise .then() or .catch(), native addEventListener callbacks, or when tests fail because they assert intermediate state after a React 18 upgrade./react18-dep-compatibilityCheck React 18.3.1 and React 19 dependency compatibility before npm installs, peer-dependency resolutions, or upgrade plans. Use when reviewing a React upgrade matrix, resolving npm peer conflicts, choosing minimum compatible package versions, deciding on --legacy-peer-deps, or separating a react-router v5 to v6 migration./react18-enzyme-to-rtlRewrite Enzyme tests for React 18 into React Testing Library behavior tests. Use when a test imports enzyme, uses shallow, mount, wrapper.find(), wrapper.simulate(), wrapper.prop(), wrapper.state(), wrapper.instance(), Enzyme configure/Adapter, or needs React 18-compatible RTL migration patterns./react18-legacy-contextMigrate React legacy context API usage from contextTypes, childContextTypes, and getChildContext to modern createContext. Use this skill when touching legacy context in class or function components because provider and every consumer must be updated together to avoid React 18 warnings and React 19 runtime failures./react18-lifecycle-patternsMigrate unsafe React class component lifecycle methods to React 18.3.1-safe patterns. Use when fixing `componentWillMount`, `componentWillReceiveProps`, `componentWillUpdate`, `UNSAFE_` lifecycle warnings, choosing `getDerivedStateFromProps` versus `componentDidUpdate`, or adding `getSnapshotBeforeUpdate`./react-audit-grep-patternsProvide verified grep command libraries for React 18.3.1 and React 19 migration audits, including deprecated APIs, removed APIs, unsafe lifecycle methods, batching risks, tests, dependencies, and peer conflicts. Use this skill when writing or running React migration audit scan commands.Other plugins' skills for the same job