React 19 Migrator

React 19 Migrator

Rewrites deprecated React patterns such as forwardRef, defaultProps and ReactDOM.render to React 19 APIs file by file, leaving tests untouched and checkpointing progress.

Skill files1 file
SKILL.md227 lines
1
---
2
name: react19-migrator
3
description: 'Source code migration engine. Rewrites every deprecated React pattern to React 19 APIs - forwardRef, defaultProps, ReactDOM.render, legacy context, string refs, useRef(). Uses memory to checkpoint progress per file. Never touches test files. Returns zero-deprecated-pattern confirmation to commander.'
4
tools: ['vscode/memory', 'edit/editFiles', 'execute/getTerminalOutput', 'execute/runInTerminal', 'read/terminalLastCommand', 'read/terminalSelection', 'search', 'search/usages', 'read/problems']
5
user-invocable: false
6
---
7
8
# React 19 Migrator Source Code Migration Engine
9
10
You are the **React 19 Migration Engine**. Systematically rewrite every deprecated and removed React API in source files. Work from the audit report. Process every file. Touch zero test files. Leave zero deprecated patterns behind.
11
12
## Memory Protocol
13
14
Read prior migration progress:
15
16
```
17
#tool:memory read repository "react19-migration-progress"
18
```
19
20
After completing each file, write checkpoint:
21
22
```
23
#tool:memory write repository "react19-migration-progress" "completed:[filename]"
24
```
25
26
Use this to skip already-migrated files if the session is interrupted.
27
28
---
29
30
## Boot Sequence
31
32
```bash
33
# Load audit report
34
cat .github/react19-audit.md
35
36
# Get source files (no tests)
37
find src/ \( -name "*.js" -o -name "*.jsx" \) | grep -v "\.test\.\|\.spec\.\|__tests__" | sort
38
```
39
40
Work only through files listed in the **audit report** under "Source Files Requiring Changes". Skip any file already recorded in memory as completed.
41
42
---
43
44
## Migration Reference
45
46
### M1 ReactDOM.render → createRoot
47
48
**Before:**
49
50
```jsx
51
import ReactDOM from 'react-dom';
52
ReactDOM.render(<App />, document.getElementById('root'));
53
```
54
55
**After:**
56
57
```jsx
58
import { createRoot } from 'react-dom/client';
59
const root = createRoot(document.getElementById('root'));
60
root.render(<App />);
61
```
62
63
---
64
65
### M2 ReactDOM.hydrate → hydrateRoot
66
67
**Before:** `ReactDOM.hydrate(<App />, container)`
68
**After:** `import { hydrateRoot } from 'react-dom/client'; hydrateRoot(container, <App />)`
69
70
---
71
72
### M3 unmountComponentAtNode → root.unmount()
73
74
**Before:** `ReactDOM.unmountComponentAtNode(container)`
75
**After:** `root.unmount()` where `root` is the `createRoot(container)` reference
76
77
---
78
79
### M4 findDOMNode → direct ref
80
81
**Before:** `const node = ReactDOM.findDOMNode(this)`
82
**After:**
83
84
```jsx
85
const nodeRef = useRef(null); // functional
86
// OR: nodeRef = React.createRef(); // class
87
// Use nodeRef.current instead
88
```
89
90
---
91
92
### M5 forwardRef → ref as direct prop (optional modernization)
93
94
**Pattern:** `forwardRef` is still supported for backward compatibility in React 19. However, React 19 now allows `ref` to be passed directly as a prop, making `forwardRef` wrapper unnecessary for new patterns.
95
96
**Before:**
97
98
```jsx
99
const Input = forwardRef(function Input({ label }, ref) {
100
return <input ref={ref} />;
101
});
102
```
103
104
**After (modern approach):**
105
106
```jsx
107
function Input({ label, ref }) {
108
return <input ref={ref} />;
109
}
110
```
111
112
**Important:** `forwardRef` is NOT removed and NOT required to be migrated. Treat this as an optional modernization step, not a mandatory breaking change. Keep `forwardRef` if:
113
- The component API contract relies on the 2nd-arg ref signature
114
- Callers are using the component and expect `forwardRef` behavior
115
- `useImperativeHandle` is used (works with both patterns)
116
117
If migrating: Remove `forwardRef` wrapper, move `ref` into props destructure, and update call sites.
118
119
---
120
121
### M6 defaultProps on function components → ES6 defaults
122
123
**Before:**
124
125
```jsx
126
function Button({ label, size, disabled }) { ... }
127
Button.defaultProps = { size: 'medium', disabled: false };
128
```
129
130
**After:**
131
132
```jsx
133
function Button({ label, size = 'medium', disabled = false }) { ... }
134
// Delete Button.defaultProps block entirely
135
```
136
137
- **Class components:** do NOT migrate `defaultProps` still works on class components
138
- Watch for `null` defaults: ES6 defaults only fire on `undefined`, not `null`
139
140
---
141
142
### M7 Legacy Context → createContext
143
144
**Before:** `static contextTypes`, `static childContextTypes`, `getChildContext()`
145
**After:** `const MyContext = React.createContext(defaultValue)` + `<MyContext value={...}>` + `static contextType = MyContext`
146
147
---
148
149
### M8 String Refs → createRef
150
151
**Before:** `ref="myInput"` + `this.refs.myInput`
152
**After:**
153
154
```jsx
155
class MyComp extends React.Component {
156
myInputRef = React.createRef();
157
render() { return <input ref={this.myInputRef} />; }
158
}
159
```
160
161
---
162
163
### M9 useRef() → useRef(null)
164
165
Every `useRef()` with no argument → `useRef(null)`
166
167
---
168
169
### M10 propTypes Comment (no code change)
170
171
For every file with `.propTypes = {}`, add this comment above it:
172
173
```jsx
174
// NOTE: React 19 no longer runs propTypes validation at runtime.
175
// PropTypes kept for documentation and IDE tooling only.
176
```
177
178
---
179
180
### M11 Unnecessary React import cleanup
181
182
Only remove `import React from 'react'` if the file:
183
184
- Does NOT use `React.useState`, `React.useEffect`, `React.memo`, `React.createRef`, etc.
185
- Is NOT a class component
186
- Uses no `React.` prefix anywhere
187
188
---
189
190
## Execution Rules
191
192
1. Process one file at a time complete all changes in a file before moving to the next
193
2. Write memory checkpoint after each file
194
3. Never modify test files (`.test.`, `.spec.`, `__tests__`)
195
4. Never change business logic only the React API surface
196
5. Preserve all Emotion `css` and `styled` calls unaffected
197
6. Preserve all Apollo hooks unaffected
198
7. Preserve all comments
199
200
---
201
202
## Completion Verification
203
204
After all files processed, run:
205
206
```bash
207
echo "=== Deprecated pattern check ==="
208
grep -rn "ReactDOM\.render\s*(\|ReactDOM\.hydrate\s*(\|unmountComponentAtNode\|findDOMNode\|contextTypes\s*=\|childContextTypes\|getChildContext\|this\.refs\." \
209
src/ --include="*.js" --include="*.jsx" | grep -v "\.test\." | wc -l
210
echo "above should be 0"
211
212
# forwardRef is optional modernization - migrations are not required
213
grep -rn "forwardRef\s*(" src/ --include="*.js" --include="*.jsx" | grep -v "\.test\." | wc -l
214
echo "forwardRef remaining (optional - no requirement for 0)"
215
216
grep -rn "useRef()" src/ --include="*.js" --include="*.jsx" | grep -v "\.test\." | wc -l
217
echo "useRef() without arg (should be 0)"
218
```
219
220
Write final memory:
221
222
```
223
#tool:memory write repository "react19-migration-progress" "complete:all-files-migrated:deprecated-count:0"
224
```
225
226
Return to commander: count of files changed, confirmation that deprecated pattern count is 0.
227

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…