Skip to content

Upgrading react-test-renderer 18 to 19

Breaking18.3.1 → 19.3.1Breaking50Security2Platform1Deprecated3New108Changed108Fixed152Other5

BreakingUpgrade verdict

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

  • If you use the recommended preset, it now uses the newer flat config format; projects still on the old format must switch to the recommended-legacy preset.
  • React.act used to be exported in production builds by mistake; it is now only available in development.
  • You can no longer pass an HTML comment as the container to render into.
  • 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 56 that need code or config changes

react-test-renderer publishes official migration guides for versions 19, 19. They cover more than the release notes do.

React 19 upgrade guide ↗Upgrade guide ↗

Drops react-shallow-renderer.

Installs 2 packages in all (was 6).

Breaking50
Makes flat config the default recommended preset and moves legacy config 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.
onUncaughtErroronCaughtErrorcreateRoothydrateRootwindow.reportErrorconsole.error
propTypes is removed and silently ignored; migrate to TypeScript or another type-checking solution.
propTypes
defaultProps is removed for function components; 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 when using a script tag.
Removes deprecated TypeScript types such as ReactChild, ReactFragment, ReactNodeArray, ReactText, VoidFunctionComponent and VFC.
ReactChildReactFragmentReactNodeArrayReactTextVoidFunctionComponentVFC
Defaults ReactElement props to unknown instead of any for stricter typing.
ReactElement
Removes the global JSX namespace; JSX is now available from the React package.
JSX
Renames the react.element symbol to react.transitional.element.
react.elementreact.transitional.element
Removes string refs.
Removes Legacy Context.
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 render, hydrate, findDOMNode, unmountComponentAtNode, unstable_createEventHandle, unstable_renderSubtreeIntoContainer, and unstable_runWithPriority; moves createRoot and…
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.
prepareUpdate
Removes isConcurrentMode and isAsyncMode methods.
isConcurrentModeisAsyncMode
Removes React internals access from useSyncExternalStore.
useSyncExternalStore
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 package or testing libraries 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; refs can accept cleanup functions and implicit returns of non-functions now error.
Requires the initial argument to useRef.
useRefuseStatecreateContext
Makes ref objects returned from useRef always mutable.
useRef()
Throws an error if react and react-dom versions do not match.
reactreact-dom
Replaces JavaScript URLs with functions that throw errors.
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
Security2
Adds more DoS mitigations to Server Actions and hardens Server Components.
Adds extra loop protection to React Server Functions.
React Server Functions
Platform1
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