React 18 to React 19 Complete Migration Guide
React 19 removes forwardRef in favor of ref as a standard prop, replaces useFormState with useActionState, and introduces native Actions.
⚡ Automated 1-Line Codemod
npx codemod@latest react/19/migration-recipe .
🚨 Breaking Changes List
- `React.forwardRef` is deprecated and element.ref is now a standard prop on function components.
- `useFormState` is moved to `react` and renamed to `useActionState`.
- `ReactDOM.render` and `unmountComponentAtNode` have been completely removed.
- `<Context.Provider>` can now be written simply as `<Context>`.
🔧 Verified Migration Diff
// React 18 -> 19 forwardRef Migration
- const MyInput = forwardRef((props, ref) => {
- return <input ref={ref} {...props} />;
- });
+ function MyInput({ ref, ...props }: { ref?: React.Ref<HTMLInputElement> }) {
+ return <input ref={ref} {...props} />;
+ }