Back to React

Migration Guide

React: 18 19

Upgrading a React app from 18 to 19

MediumEstimated time: 2-4 hours

Upgrading React from 18 to 19

Key changes in React 19

  • ref is now passed as a normal prop to function components; forwardRef is no longer required and is deprecated for new code.
  • Actions and the useActionState, useOptimistic, and use hooks are stable.
  • defaultProps for function components is removed (it was deprecated in 18.3).
  • Legacy context types and string refs (long deprecated) are gone.
  • The React Compiler is optional tooling that can reduce manual memoization; it is not required for the upgrade.

Migration steps

Step 1: Update packages

npm install react@19 react-dom@19

Step 2: Apply the official codemods

The React team ships codemods that rewrite most mechanical changes:

npx types-react-codemod@latest preset-19-from-18

Step 3: Fix remaining manual items

  • Replace forwardRef wrappers with plain props.
  • Move defaultProps on function components to normal parameters.
  • Search for string ref usage and module-level contextTypes.

Step 4: Test

npm test
npm run build

Compatibility checklist

  • Third-party component libraries must declare React 19 support; most major ones released updates.
  • TypeScript users need the newest @types/react and @types/react-dom.
  • Hydration errors are stricter; fix them as they surface rather than muting warnings.

Resources