Skip to content

Upgrading react 18 to 19

Breaking18.3.1 → 19.3.1Breaking50Security3Platform1Deprecated3New107Changed106Fixed154Other5

BreakingUpgrade verdict

50 breaking changes and a platform requirement change and 3 security fixes.

  • If you use the plugin's recommended settings, you now get the flat config format by default; the old format is under a new name.
  • Code that called React.act in production builds will break because it is now only available in development.
  • Passing an HTML comment as the container to render into no longer works.
  • Rendering errors are now reported to the browser or console instead of being thrown again, and you can customize how they are handled.
Top 5 of 57 that need code or config changes

react publishes an official migration guide for version 19. It covers more than the release notes do.

React 19 upgrade guide ↗

Drops loose-envify.

Installs 0 packages in all (was 2).

Breaking50
Flat config becomes the default recommended preset; legacy config moves to recommended-legacy.
recommendedrecommended-legacy
Fixes dev-only methods being exported in production builds; React.act is no longer available in production builds.
React.act
Removes support for using HTML comments (e.g. <!-- -->) as a DOM container.
Errors in render are no longer re-thrown; uncaught errors go to window.reportError and caught ones to console.error, customizable via onUncaughtError and onCaughtError.
onUncaughtErroronCaughtErrorcreateRoothydrateRoot
propTypes is removed and silently ignored; migrate to TypeScript or another type-checking solution.
propTypes
defaultProps for function components is removed; use ES6 default parameters instead. Class components still support defaultProps.
defaultProps
contextTypes and getChildContext are removed; legacy Context for class components is replaced by the contextType API.
contextTypesgetChildContextcontextType
String refs are removed; migrate any usage to ref callbacks.
Module pattern factories are removed; migrate to regular functions.
React.createFactory is removed; migrate all createFactory usage to JSX components.
React.createFactory
ReactDOM.render and ReactDOM.hydrate are removed in favor of ReactDOM.createRoot and ReactDOM.hydrateRoot.
ReactDOM.renderReactDOM.hydrateReactDOM.createRootReactDOM.hydrateRoot
unmountComponentAtNode is removed in favor of root.unmount().
unmountComponentAtNoderoot.unmount()
ReactDOM.findDOMNode is removed; replace it with DOM refs.
ReactDOM.findDOMNode
UMD builds are removed; load React 19 with an ESM-based CDN such as esm.sh instead.
Removes deprecated TypeScript types ReactChild, ReactFragment, ReactNodeArray, ReactText, VoidFunctionComponent and VFC.
ReactChildReactFragmentReactNodeArrayReactTextVoidFunctionComponentVFC
ReactElement props now default to unknown instead of any when the element is typed as ReactElement.
ReactElement
Removes the global JSX namespace; JSX is now available from the React package via import { JSX } from 'react'.
JSX
Renames the react.element symbol to react.transitional.element.
react.elementreact.transitional.element
Removes string refs.
Removes Legacy Context.
contextTypeschildContextTypes
Removes RefreshRuntime.findAffectedHostInstances.
RefreshRuntime.findAffectedHostInstances
Removes client caching from the cache() API.
cache()
Removes propTypes.
propTypes
Removes defaultProps support, except for classes.
defaultProps
Removes UMD builds.
Removes createFactory from React.
createFactory
Removes legacy React DOM APIs and moves createRoot and hydrateRoot to react-dom/client.
renderhydratefindDOMNodeunmountComponentAtNodeunstable_createEventHandleunstable_renderSubtreeIntoContainerunstable_runWithPrioritycreateRoot
Removes unstable_flushControlled.
unstable_flushControlled
Removes legacy mode.
Removes renderToStaticNodeStream().
renderToStaticNodeStream()
Removes unstable_renderSubtreeIntoContainer.
unstable_renderSubtreeIntoContainer
Renames the secret export of Client and Server internals.
Removes errorInfo.digest from onRecoverableError.
onRecoverableErrorerrorInfo.digest
Removes prepareUpdate from React Reconciler.
prepareUpdate
Removes isConcurrentMode and isAsyncMode methods from react-is.
isConcurrentModeisAsyncMode
Removes React internals access from useSyncExternalStore.
useSyncExternalStore
Releases eslint-plugin-react-hooks 6.1.0 as the first official 6.x major release with breaking changes.
eslint-plugin-react-hooks
Updates useId to use valid CSS selectors, changing the format from :r123: to «r123».
useId
The new JSX transform is now required, enabling ref as a prop and JSX speed improvements.
react-test-renderer/shallow is removed; use the third-party react-shallow-renderer or React Testing Library instead.
react-test-renderer/shallow
react-dom/test-utils is removed; act moved to react and all other utilities are removed.
react-dom/test-utilsact
Moves Requireable, ValidationMap, Validator and WeakValidationMap types to prop-types.
RequireableValidationMapValidatorWeakValidationMap
Moves ClassicComponentClass, ClassicComponent, ClassicElement, ComponentSpec, Mixin, ReactChildren, ReactHTML, ReactSVG and SFCFactory types to create-react-class.
ClassicComponentClassClassicComponentClassicElementComponentSpecMixinReactChildrenReactHTMLReactSVG
Disallows implicit returns in refs since refs can now accept cleanup functions; implicit returns of non-functions now error.
Requires the initial argument to useRef, matching useState and createContext.
useRefuseStatecreateContext
Ref objects returned from useRef() are now always mutable instead of sometimes immutable.
useRef()
Throws an error if react and react-dom versions do not match.
reactreact-dom
Removes test-utils.
test-utils
Removes the react-test-renderer/shallow export.
react-test-renderer/shallow
Adjusts parameter order of createContainer and createHydrationContainer after on* handlers for upcoming experimental APIs.
createContainercreateHydrationContainer
Security3
Patches Promise cycles and toString on Server Functions.
toStringServer Functions
Adds more DoS mitigations to Server Actions and hardens Server Components.
Server ActionsServer Components
Replaces javascript: URLs with functions that throw errors.
Platform1
eslint-plugin-react-hooks@6.1.0 requires Node.js 18 or newer.
Deprecated3
Deprecates element.ref access in favor of element.props.ref, warning when accessed.
element.refelement.props.ref
react-test-renderer logs a deprecation warning and switches to concurrent rendering for web usage.
react-test-renderer
Adds a deprecation error to react-test-renderer on web.
react-test-renderer