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.
In plain terms
- 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.
Must act 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).
What you must change
Breaking50
Makes flat config the default recommended preset and moves legacy config to recommended-legacy.
recommendedrecommended-legacyFixes dev-only methods being exported in production builds; React.act is no longer available in production builds.
React.actRemoves 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.errorpropTypes is removed and silently ignored; migrate to TypeScript or another type-checking solution.
propTypesdefaultProps is removed for function components; use ES6 default parameters instead. Class components still support defaultProps.
defaultPropscontextTypes and getChildContext are removed; legacy Context for class components is replaced by the contextType API.
contextTypesgetChildContextcontextTypeString 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.createFactoryReactDOM.render and ReactDOM.hydrate are removed in favor of ReactDOM.createRoot and ReactDOM.hydrateRoot.
ReactDOM.renderReactDOM.hydrateReactDOM.createRootReactDOM.hydrateRootunmountComponentAtNode is removed in favor of root.unmount().
unmountComponentAtNoderoot.unmount()ReactDOM.findDOMNode is removed; replace it with DOM refs.
ReactDOM.findDOMNodeUMD 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.
ReactChildReactFragmentReactNodeArrayReactTextVoidFunctionComponentVFCDefaults ReactElement props to unknown instead of any for stricter typing.
ReactElementRemoves the global JSX namespace; JSX is now available from the React package.
JSXRenames the react.element symbol to react.transitional.element.
react.elementreact.transitional.elementRemoves string refs.
Removes Legacy Context.
Removes RefreshRuntime.findAffectedHostInstances.
RefreshRuntime.findAffectedHostInstancesRemoves client caching from the cache() API.
cache()Removes propTypes.
propTypesRemoves defaultProps support, except for classes.
defaultPropsRemoves UMD builds.
Removes
createFactory from React.createFactoryRemoves
render, hydrate, findDOMNode, unmountComponentAtNode, unstable_createEventHandle, unstable_renderSubtreeIntoContainer, and unstable_runWithPriority; moves createRoot and…renderhydratefindDOMNodeunmountComponentAtNodeunstable_createEventHandleunstable_renderSubtreeIntoContainerunstable_runWithPrioritycreateRootRemoves
unstable_flushControlled.unstable_flushControlledRemoves legacy mode.
Removes
renderToStaticNodeStream().renderToStaticNodeStream()Removes
unstable_renderSubtreeIntoContainer.unstable_renderSubtreeIntoContainerRenames the secret export of Client and Server internals.
Removes
errorInfo.digest from onRecoverableError.onRecoverableErrorerrorInfo.digestRemoves
prepareUpdate.prepareUpdateRemoves
isConcurrentMode and isAsyncMode methods.isConcurrentModeisAsyncModeRemoves React internals access from
useSyncExternalStore.useSyncExternalStoreUpdates useId to use valid CSS selectors, changing the format from :r123: to «r123».
useIdThe 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/shallowreact-dom/test-utils is removed; act moved to react and all other utilities are removed.
react-dom/test-utilsactMoves Requireable, ValidationMap, Validator and WeakValidationMap types to prop-types.
RequireableValidationMapValidatorWeakValidationMapMoves ClassicComponentClass, ClassicComponent, ClassicElement, ComponentSpec, Mixin, ReactChildren, ReactHTML, ReactSVG and SFCFactory types to create-react-class.
ClassicComponentClassClassicComponentClassicElementComponentSpecMixinReactChildrenReactHTMLReactSVGDisallows implicit returns in refs; refs can accept cleanup functions and implicit returns of non-functions now error.
Requires the initial argument to useRef.
useRefuseStatecreateContextMakes ref objects returned from useRef always mutable.
useRef()Throws an error if
react and react-dom versions do not match.reactreact-domReplaces JavaScript URLs with functions that throw errors.
Removes
test-utils.test-utilsRemoves the
react-test-renderer/shallow export.react-test-renderer/shallowAdjusts parameter order of
createContainer and createHydrationContainer after on* handlers for upcoming experimental APIs.createContainercreateHydrationContainerSecurity2
Adds more DoS mitigations to Server Actions and hardens Server Components.
Adds extra loop protection to React Server Functions.
React Server FunctionsPlatform1
Requires Node.js 18 or newer.
Deprecations to plan for
Deprecated3
Deprecates element.ref access in favor of element.props.ref, warning when accessed.
element.refelement.props.refreact-test-renderer logs a deprecation warning and switches to concurrent rendering for web usage.
react-test-rendererAdds a deprecation error to
react-test-renderer on web.react-test-renderer