React 17 makes upgrades easier

Support for gradual updates in React 17 should make it safer to mix different versions of React in the same app

React 17 makes upgrades easier
Thinkstock

React 17, the latest version of the JavaScript UI library from Facebook, has arrived. The new release, designed to serve as a stepping stone, lacks any new developer-facing features but instead focuses on making upgrades easier.

Unveiled October 20, React 17 enables gradual React upgrades. When moving from React 15 to React 16 or from React 16 to React 17, users usually would upgrade the entire app at once. While this works well for many apps, it can be challenging if the codebase was written more than a few years ago and was not actively maintained.

Although it is possible to use two versions of React on the same web page, this has been fragile and has caused problems with events. Many of these problems are being fixed with React 17. Thus, when React 18 and subsequent versions are published, developers will be able to upgrade an app either all at once or piece by piece.

With React 17, it becomes safer to embed a tree managed by one version of React into a different version of the library. React 17 also makes it easier to embed React into apps that were built with other technologies.

To enable gradual updates, changes have been made to the React event system; these changes are potentially breaking. A FAQ has been published pertaining to stability.

In addition, React 17 introduces support for a new JSX transform, and that support is backported to older versions of React as well. The new transform is offered on an opt-in basis.

To install React 17 from NPM, you can use the following command:

npm install react@17.0.0 react-dom@17.0.0

From Yarn, use:

yarn add react@17.0.0 react-dom@17.0.0

Copyright © 2020 IDG Communications, Inc.