Today we release React 17! We have been writing for a long time about the role of React 17 and the changes it contains React 17 RC blog post. This message is a brief summary of it, so if you have already read the RC message, you can skip this.

No new features

React 17 is unusual in that it does not add new features for developers. Instead, this publication focuses primarily on which makes it easier to update React itself.

In particular, React 17 is a “stepping stone” release that makes it safer to immerse a tree controlled by one version of React inside a tree managed by a different version of React.

It also makes it easier to embed React in applications built on other technologies.

Gradual updates

React 17 allows for a gradual React upgrade. When you upgrade from React 15 to 16 (or this time from React 16 to 17), you usually upgrade your entire app at once. This works well in many applications. But it can be even more challenging if the code template was written more than a few years ago and is not actively maintained. And while it is possible to use two versions of React on the page, until reaction 17 it has been fragile and has caused problems with events.

We will fix many of these issues with React 17. this means that when React 18 and subsequent upcoming versions appear, you now have more options. The first option is to update your entire application at once, as you may have done before. But you also have the option to update your app piece by piece. For example, you might decide to move most of your application to React 18, but keep some lazy downloaded dialog box or subroutine in React 17.

This does not mean you must make incremental updates. Updating most applications at once is still the best solution. Downloading two versions of React – even if one is lazily downloaded on demand – is still not ideal. For larger applications that are not actively maintained, this option makes sense to consider, and React 17 allows these applications to be left behind.

We have manufactured example warehouse showing how lazy to download an older version of React if necessary. This demo uses Create React, but it should be possible to follow a similar approach with any other tool. We welcome demos that use other tools as bet requests.

Entry

We are postponed other changes only after reaction 17. The goal of this publication is to enable incremental updates. If upgrading to React 17 were too difficult, it would lose its purpose.

Changes to event delegation

To implement incremental updates, we need to make some changes to the React event system. React 17 is a major release because these changes can break. You can check us out version version FAQ learn more about our commitment to stability.

In React 17, React no longer attaches event handlers document level under the hood. Instead, it attaches them to the root DOM, where the React tree is rendered:

const rootNode = document.getElementById('root');
ReactDOM.render(<App />, rootNode);

React in 16 and earlier React would do document.addEventListener() for most events. React 17 calls rootNode.addEventListener() instead under the Hood.



We have confirmed it several problems reported over years on our problem tracking Problems with integrating React into non-React code have been fixed with the new behavior.

If you’re having trouble with this change, here is a common way to solve them.

Other breaking changes

React 17 RC blog post describes the remainder of the 17 disruptive changes in reaction.

We’ve only had to change less than 20 components out of 100,000+ in the Facebook product code to work with these changes We expect most applications to be able to upgrade to React 17 without too much hassle. Please tell us if you encounter problems.

New JSX variant

React 17 supports new JSX variant. We have also supported its support for React 16.14.0, React 15.7.0 and 0.14.10. Note that it is completely optional and you do not need to use it. The classic JSX variant will continue to run and is not scheduled to stop supporting it.

Reacts Native

React Native has a separate release schedule. We got support for React 17 in React Native 0.64. As always, you can follow React Native Community publishing discussions monitoring the problem.

Installation

To install React 17 at npm, run:

npm install react@17.0.0 react-dom@17.0.0

To install React 17 with Wire, run:

yarn add react@17.0.0 react-dom@17.0.0

We also offer React’s UMD structures via CDN:

<script crossorigin src="https://unpkg.com/react@17.0.0/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17.0.0/umd/react-dom.production.min.js"></script>

See the documentation detailed installation instructions.

Change log

React

React to the DOM

Responds to the DOM server

  • Make useCallback in accordance with the conduct useMemo for server rendering. (@lexmckenley in # 18783)
  • Correct the leaking condition when the action component throws. (@pmaccart in # 19212)

The test renderer responds

Simultaneous mode (experimental)

LEAVE A REPLY

Please enter your comment!
Please enter your name here