Home / Blog / Upgrading React 16 to 18 without freezing the roadmap

Blog

Upgrading React 16 to 18 without freezing the roadmap

4 min read · React · Migration · Release management

A console several majors behind, a team still shipping features, and a release train that could not stop. The upgrade worked because it was treated as a series of small, audited releases — not a project.

Audit before you touch package.json

Every major starts with a written breaking-change audit: read the changelog and the migration guide, then search the codebase for each pattern they mention. The point is not to be thorough for its own sake. It is to turn "upgrade React" from a vague fear into a list someone can estimate, split, and review.

For React 18 the audit is short, but every line on it can bite:

  • ReactDOM.render and hydrate → createRoot and hydrateRoot. Usually only the entry points.
  • Automatic batching. Search for code that reads the DOM or state between two setState calls inside a promise, timeout, or native event handler.
  • StrictMode runs effects twice in development. Every useEffect that subscribes, polls, or opens a socket needs a cleanup.
  • @types/react 18 drops the implicit children prop from React.FC. Every component that renders props.children without declaring it fails to compile.
  • Third-party peer ranges. Anything pinned to react@^16 || ^17 needs an upgrade or a replacement before the bump.

Each line gets a count of affected files and an owner. A five-line list with numbers next to it is something a reviewer can sign off; "upgrade React" is not.

The changes that actually bite

The entry point is the easy part, and the one most guides lead with:

// React 16 / 17
import ReactDOM from 'react-dom';
ReactDOM.render(<App />, document.getElementById('root'));

// React 18
import { createRoot } from 'react-dom/client';
createRoot(document.getElementById('root')!).render(<App />);

Until you make that switch, React 18 runs in legacy mode, so the version bump can be its own release with the new behaviour turned on in the next. That alone takes half the risk out of the upgrade.

Automatic batching is the quiet one. In React 17, state updates inside a promise callback rendered one at a time; in 18 they are batched into a single render:

fetchBooking(id).then((booking) => {
  setBooking(booking);
  setLoading(false);
  // React 17: two renders. React 18: one.
});

For almost every component that is a free performance win. It breaks only code that quietly depended on the intermediate render — measuring a node or scrolling into view between the two updates. flushSync is the escape hatch, and the audit tells you exactly where to use it.

StrictMode double-mounting is the loud one, and it is worth welcoming rather than silencing. It surfaces effects that subscribe without cleaning up — bugs that already existed and simply were not visible yet:

useEffect(() => {
  const timer = setInterval(refresh, 30_000);
  return () => clearInterval(timer); // without this, StrictMode starts two timers
}, [refresh]);

One upgrade line per release

React, Node, the UI kit, and the component library each moved on their own, never in the same cut. When something breaks after a release that changed one thing, you know what broke it. When it breaks after a release that changed four, you spend the afternoon bisecting instead of fixing.

Node gets the same treatment as React: the audit covers the CI image, the engines field in package.json, and any native modules that need a rebuild. Going from 14 to 24 LTS is a long jump on paper, but each step is a small, boring release.

Small steps also let each upgrade ride the normal release train alongside feature work, instead of waiting for a dedicated "migration sprint" that never gets approved.

The regression checklist is the real deliverable

An upgrade is only done when the flows people use every day have been walked through on staging. The checklist is written before the upgrade lands, so "it works on my machine" never stands in for "it works for operations". A shortened version of the shape:

  • Create, edit, and cancel a booking.
  • Take a transaction through to a receipt, including the price breakdown.
  • Open, update, and close a customer case.
  • Run a bulk action on a filtered table.
  • Sign out and back in; an expired session redirects cleanly.

None of these test React. They test what React is for. That is why the same checklist works for the Node upgrade, the UI-kit upgrade, and the next one nobody has planned yet.

Spike the risky part, then decide

Not every upgrade belongs on the roadmap straight away. A bundler migration got a time-boxed spike first: enough to see what breaks and what it would cost, written down so the decision could be made on evidence instead of enthusiasm.

The audits are the part that outlives the upgrade. The next major starts from the last audit as a template, which is the closest thing a frontend team has to making upgrades boring.

Hiring a senior frontend engineer?

Open to senior frontend roles — remote or relocation. Email gets the fastest reply.

← All posts