MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

React19-Migrator

React19-Migrator是一款code方向的AI技能,核心价值是Source code migration engine,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

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 pro

Last verified on: 2026-05-30
mkdir -p ./skills/react19-migrator && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/react19-migrator/SKILL.md -o ./skills/react19-migrator/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# React 19 Migrator Source Code Migration Engine


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.


Memory Protocol


Read prior migration progress:


text
#tool:memory read repository "react19-migration-progress"

After completing each file, write checkpoint:


text
#tool:memory write repository "react19-migration-progress" "completed:[filename]"

Use this to skip already-migrated files if the session is interrupted.


---


Boot Sequence


bash
# Load audit report
cat .github/react19-audit.md

# Get source files (no tests)
find src/ \( -name "*.js" -o -name "*.jsx" \) | grep -v "\.test\.\|\.spec\.\|__tests__" | sort

Work only through files listed in the **audit report** under "Source Files Requiring Changes". Skip any file already recorded in memory as completed.


---


Migration Reference


M1 ReactDOM.render → createRoot


**Before:**


jsx
import ReactDOM from 'react-dom';
ReactDOM.render(<App />, document.getElementById('root'));

**After:**


jsx
import { createRoot } from 'react-dom/client';
const root = createRoot(document.getElementById('root'));
root.render(<App />);

---


M2 ReactDOM.hydrate → hydrateRoot


**Before:** `ReactDOM.hydrate(<App />, container)`

**After:** `import { hydrateRoot } from 'react-dom/client'; hydrateRoot(container, <App />)`


---


M3 unmountComponentAtNode → root.unmount()


**Before:** `ReactDOM.unmountComponentAtNode(container)`

**After:** `root.unmount()` where `root` is the `createRoot(container)` reference


---


M4 findDOMNode → direct ref


**Before:** `const node = ReactDOM.findDOMNode(this)`

**After:**


jsx
const nodeRef = useRef(null); // functional
// OR: nodeRef = React.createRef(); // class
// Use nodeRef.current instead

---


M5 forwardRef → ref as direct prop (optional modernization)


**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.


**Before:**


jsx
const Input = forwardRef(function Input({ label }, ref) {
  return <input ref={ref} />;
});

**After (modern approach):**


jsx
function Input({ label, ref }) {
  return <input ref={ref} />;
}

**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:

- The component API contract relies on the 2nd-arg ref signature

- Callers are using the component and expect `forwardRef` behavior

- `useImperativeHandle` is used (works with both patterns)


If migrating: Remove `forwardRef` wrapper, move `ref` into props destructure, and update call sites.


---


M6 defaultProps on function components → ES6 defaults


**Before:**


jsx
function Button({ label, size, disabled }) { ... }
Button.defaultProps = { size: 'medium', disabled: false };

**After:**


jsx
function Button({ label, size = 'medium', disabled = false }) { ... }
// Delete Button.defaultProps block entirely

- **Class components:** do NOT migrate `defaultProps` still works on class components

- Watch for `null` defaults: ES6 defaults only fire on `undefined`, not `null`


---


M7 Legacy Context → createContext


**Before:** `static contextTypes`, `static childContextTypes`, `getChildContext()`

**After:** `const MyContext = React.createContext(defaultValue)` + `<MyContext value={...}>` + `static contextType = MyContext`


---


M8 String Refs → createRef


**Before:** `ref="myInput"` + `this.refs.myInput`

**After:**


jsx
class MyComp extends React.Component {
  myInputRef = React.createRef();
  render() { return <input ref={this.myInputRef} />; }
}

---


M9 useRef() → useRef(null)


Every `useRef()` with no argument → `useRef(nu

🎯 Best For

  • Claude users
  • GitHub Copilot users
  • Software engineers
  • Development teams
  • Tech leads

💡 Use Cases

  • React component optimization
  • Hook dependency audits

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply React19-Migrator to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Is React19-Migrator compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for React19-Migrator?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install React19-Migrator?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/react19-migrator/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills