Skip to content

Upgrading react-test-renderer 17 to 18

Breaking17.0.2 → 18.3.1Breaking12Deprecated16New29Changed36Fixed32

BreakingUpgrade verdict

11 breaking changes.

  • An experimental tracing API in the scheduler package has been removed.
  • React no longer bundles a polyfill for Object.assign.
  • An undocumented internal API is gone.
  • Putting elements or multiple children inside a title tag now fails instead of rendering markup browsers would not accept.
Top 5 of 26 that need code or config changes

react-test-renderer publishes an official migration guide for version 18. It covers more than the release notes do.

React 18 upgrade guide ↗

Drops object-assign.

Breaking11
Removes the unstable scheduler/tracing API.
scheduler/tracing
Removes the object-assign polyfill.
object-assign
Removes the unsupported unstable_changedBits API.
unstable_changedBits
Disallows complex children inside title elements to match browser constraints.
title
Introduces automatic batching of more state updates, with flushSync available to opt out.
flushSync
Adds a development-only Strict Mode check that unmounts and remounts every component on first mount, restoring previous state.
StrictMode
Makes useEffect timing consistent by synchronously flushing effect functions when an update is triggered during a discrete input event.
useEffect
Treats hydration mismatches from missing or extra text content as errors and reverts to client rendering up to the closest Suspense boundary.
Suspense
Keeps Suspense trees consistent by discarding an incomplete tree when a component suspends before being fully added, then retrying rendering from scratch.
Suspense
Layout effects are now cleaned up when a tree re-suspends and re-created when the boundary content is shown again.
Throws when act is used in production.
act
Deprecated15
Warns for deprecated findDOMNode outside StrictMode.
findDOMNode
Warns for deprecated test-utils methods.
test-utils
Warns for deprecated Legacy Context outside StrictMode.
Warns for deprecated string refs outside StrictMode.
Warns for deprecated defaultProps for function components.
defaultProps
Warns when using act from test-utils.
acttest-utils
Warns for deprecated unmountComponentAtNode.
unmountComponentAtNode
Warns for deprecated renderToStaticNodeStream.
renderToStaticNodeStream
Discourages the existing renderToString method, which keeps working.
renderToString
Deprecates ReactDOM.render, which now warns and runs the app in React 17 mode.
ReactDOM.renderReactDOM.hydrate
Deprecates ReactDOM.unmountComponentAtNode.
ReactDOM.unmountComponentAtNode
Deprecates ReactDOM.renderSubtreeIntoContainer.
ReactDOM.renderSubtreeIntoContainer
Deprecates ReactDOMServer.renderToNodeStream.
ReactDOMServer.renderToNodeStream
Warns if renderSubtreeIntoContainer is called.
renderSubtreeIntoContainer
Deprecates renderToNodeStream.
renderToNodeStream