Version 17 of the component-based view library from Facebook is receiving a major update without new features, but with significant upgrade improvements for the future.
The first React 17 release candidate is here. Two and a half years after the release of the last major update, there is now a successor, which, however, has a special feature: Version 17 does not contain any new dev-facing features. Instead, version 17 focuses on making upgrades easier.
New React features are in the outsourcing works, but the decision was made against rolling them out with React 17, according to the blog post on the release. Instead, version 17 should be understood as a milestone in the React release history, which aims to make it easier in the future to use different versions of React in parallel in a project. Previous React upgrades have been an “all or nothing” issue. Either you stayed with the old version or you migrated your entire app to the new release. There was no in between. This approach worked well until it stopped: Some API changes, for example deprecating the legacy context API, cannot be automated just like that. Modern apps normally no longer use these apps, but React still supports the API. This gave the React Core team the choice of either continuing to support this API or denying future upgrades to all apps that were still using the API.
The innovation: Gradual upgrades
React 17 now enables gradual upgrades for the first time. Up to version 17, migrating from version to version meant upgrading the entire app at once. In most cases this is not a problem either. For codebases that are a few years old and are not actively maintained, this is more difficult. Although it was previously possible to use two versions of React in parallel, this architecture is fragile and causes problems with events. React 17 creates the prerequisites so that you will no longer have these problems with future major upgrades. If you then update from version 17 to version 18, in addition to the default – to update everything at once – you have at least the option to leave parts of your application on an older version. In future, you will also have the option of upgrading apps with dependencies that are no longer supported by the current version.
There are only new features in version 18
The core team has postponed the introduction of further new features to upcoming releases. Still, version 17 is a major release. The reason: In order to enable these piecemeal upgrades, some potentially incompatible changes to React’s event system were necessary. For most apps, however, the upgrade should be largely problem-free. If you run into problems, you can open a corresponding issue.
So that you can see the whole thing in action, there is also a demo repository that shows how you can lazy-load an older version of React.
However, there are some other minor breaking changes. Version 17 brings improvements in browser compatibility and Reacts error handling, and so-called private dependencies have been removed. If you are interested in this and the changes to React’s event delegation mechanism in detail, please refer to the official blog post for the release.
You can install the release candidate via npm:
npm install firstname.lastname@example.org email@example.com
or alternatively via yarn:
yarn add firstname.lastname@example.org email@example.com
Alternatively, you can also integrate the new version into your projects as a UMD via CDN:
<script crossorigin src="https://firstname.lastname@example.org/umd/react.production.min.js"></script> <script crossorigin src="https://email@example.com/umd/react-dom.production.min.js"></script>
You can find more detailed installation instructions in the documentation.
More on the subject: