<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[React]]></title><description><![CDATA[Une bibliothèque JavaScript pour créer des interfaces utilisateurs]]></description><link>https://fr.reactjs.org</link><generator>GatsbyJS</generator><lastBuildDate>Sat, 22 Apr 2023 01:27:03 GMT</lastBuildDate><item><title><![CDATA[React Labs: What We've Been Working On – June 2022]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p><a href="https://reactjs.org/blog/2022/03/29/react-v18.html" target="_blank" rel="nofollow noopener noreferrer">React 18</a> was years in the making, and with it brought valuable lessons for the React team. Its release was the result of many years of research and exploring many paths. Some of those paths were successful; many more were dead-ends that led to new insights. One lesson we’ve learned is that it’s frustrating for the community to wait for new features without having insight into these paths that we’re exploring.</p>
<p>We typically have a number of projects being worked on at any time, ranging from the more experimental to the clearly defined. Looking ahead, we’d like to start regularly sharing more about what we’ve been working on with the community across these projects.</p>
<p>To set expectations, this is not a roadmap with clear timelines. Many of these projects are under active research and are difficult to put concrete ship dates on. They may possibly never even ship in their current iteration depending on what we learn. Instead, we want to share with you the problem spaces we’re actively thinking about, and what we’ve learned so far.</p>
<h2 id="server-components"><a href="#server-components" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Server Components </h2>
<p>We announced an <a href="https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html" target="_blank" rel="nofollow noopener noreferrer">experimental demo of React Server Components</a> (RSC) in December 2020. Since then we’ve been finishing up its dependencies in React 18, and working on changes inspired by experimental feedback.</p>
<p>In particular, we’re abandoning the idea of having forked I/O libraries (eg react-fetch), and instead adopting an async/await model for better compatibility. This doesn’t technically block RSC’s release because you can also use routers for data fetching. Another change is that we’re also moving away from the file extension approach in favor of <a href="https://github.com/reactjs/rfcs/pull/189#issuecomment-1116482278" target="_blank" rel="nofollow noopener noreferrer">annotating boundaries</a>.</p>
<p>We’re working together with Vercel and Shopify to unify bundler support for shared semantics in both Webpack and Vite. Before launch, we want to make sure that the semantics of RSCs are the same across the whole React ecosystem. This is the major blocker for reaching stable.</p>
<h2 id="asset-loading"><a href="#asset-loading" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Asset Loading </h2>
<p>Currently, assets like scripts, external styles, fonts, and images are typically preloaded and loaded using external systems. This can make it tricky to coordinate across new environments like streaming, server components, and more.
We’re looking at adding APIs to preload and load deduplicated external assets through React APIs that work in all React environments.</p>
<p>We’re also looking at having these support Suspense so you can have images, CSS, and fonts that block display until they’re loaded but don’t block streaming and concurrent rendering. This can help avoid <a href="https://twitter.com/sebmarkbage/status/1516852731251724293" target="_blank" rel="nofollow noopener noreferrer">“popcorning“</a> as the visuals pop and layout shifts.</p>
<h2 id="static-server-rendering-optimizations"><a href="#static-server-rendering-optimizations" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Static Server Rendering Optimizations </h2>
<p>Static Site Generation (SSG) and Incremental Static Regeneration (ISR) are great ways to get performance for cacheable pages, but we think we can add features to improve performance of dynamic Server Side Rendering (SSR) – especially when most but not all of the content is cacheable. We’re exploring ways to optimize server rendering utilizing compilation and static passes.</p>
<h2 id="react-compiler"><a href="#react-compiler" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Optimizing Compiler </h2>
<p>We gave an <a href="https://www.youtube.com/watch?v=lGEMwh32soc" target="_blank" rel="nofollow noopener noreferrer">early preview</a> of React Forget at React Conf 2021. It’s a compiler that automatically generates the equivalent of <code class="gatsby-code-text">useMemo</code> and <code class="gatsby-code-text">useCallback</code> calls to minimize the cost of re-rendering, while retaining React’s programming model.</p>
<p>Recently, we finished a rewrite of the compiler to make it more reliable and capable. This new architecture allows us to analyze and memoize more complex patterns such as the use of <a href="https://react.dev/learn/keeping-components-pure#local-mutation-your-components-little-secret" target="_blank" rel="nofollow noopener noreferrer">local mutations</a>, and opens up many new compile-time optimization opportunities beyond just being on par with memoization hooks.</p>
<p>We’re also working on a playground for exploring many aspects of the compiler. While the goal of the playground is to make development of the compiler easier, we think that it will make it easier to try it out and build intuition for what the compiler does. It reveals various insights into how it works under the hood, and live renders the compiler’s outputs as you type. This will be shipped together with the compiler when it’s released.</p>
<h2 id="offscreen"><a href="#offscreen" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Offscreen </h2>
<p>Today, if you want to hide and show a component, you have two options. One is to add or remove it from the tree completely. The problem with this approach is that the state of your UI is lost each time you unmount, including state stored in the DOM, like scroll position.</p>
<p>The other option is to keep the component mounted and toggle the appearance visually using CSS. This preserves the state of your UI, but it comes at a performance cost, because React must keep rendering the hidden component and all of its children whenever it receives new updates.</p>
<p>Offscreen introduces a third option: hide the UI visually, but deprioritize its content. The idea is similar in spirit to the <code class="gatsby-code-text">content-visibility</code> CSS property: when content is hidden, it doesn’t need to stay in sync with the rest of the UI. React can defer the rendering work until the rest of the app is idle, or until the content becomes visible again.</p>
<p>Offscreen is a low level capability that unlocks high level features. Similar to React’s other concurrent features like <code class="gatsby-code-text">startTransition</code>, in most cases you won’t interact with the Offscreen API directly, but instead via an opinionated framework to implement patterns like:</p>
<ul>
<li><strong>Instant transitions.</strong> Some routing frameworks already prefetch data to speed up subsequent navigations, like when hovering over a link. With Offscreen, they’ll also be able to prerender the next screen in the background.</li>
<li><strong>Reusable state.</strong> Similarly, when navigating between routes or tabs, you can use Offscreen to preserve the state of the previous screen so you can switch back and pick up where you left off.</li>
<li><strong>Virtualized list rendering.</strong> When displaying large lists of items, virtualized list frameworks will prerender more rows than are currently visible. You can use Offscreen to prerender the hidden rows at a lower priority than the visible items in the list.</li>
<li><strong>Backgrounded content.</strong> We’re also exploring a related feature for deprioritizing content in the background without hiding it, like when displaying a modal overlay.</li>
</ul>
<h2 id="transition-tracing"><a href="#transition-tracing" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Transition Tracing </h2>
<p>Currently, React has two profiling tools. The <a href="https://reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html" target="_blank" rel="nofollow noopener noreferrer">original Profiler</a> shows an overview of all the commits in a profiling session. For each commit, it also shows all components that rendered and the amount of time it took for them to render. We also have a beta version of a <a href="https://github.com/reactwg/react-18/discussions/76" target="_blank" rel="nofollow noopener noreferrer">Timeline Profiler</a> introduced in React 18 that shows when components schedule updates and when React works on these updates. Both of these profilers help developers identify performance problems in their code.</p>
<p>We’ve realized that developers don’t find knowing about individual slow commits or components out of context that useful. It’s more useful to know about what actually causes the slow commits. And that developers want to be able to track specific interactions (eg a button click, an initial load, or a page navigation) to watch for performance regressions and to understand why an interaction was slow and how to fix it.</p>
<p>We previously tried to solve this issue by creating an <a href="https://gist.github.com/bvaughn/8de925562903afd2e7a12554adcdda16" target="_blank" rel="nofollow noopener noreferrer">Interaction Tracing API</a>, but it had some fundamental design flaws that reduced the accuracy of tracking why an interaction was slow and sometimes resulted in interactions never ending. We ended up <a href="https://github.com/facebook/react/pull/20037" target="_blank" rel="nofollow noopener noreferrer">removing this API</a> because of these issues.</p>
<p>We are working on a new version for the Interaction Tracing API (tentatively called Transition Tracing because it is initiated via <code class="gatsby-code-text">startTransition</code>) that solves these problems.</p>
<h2 id="new-react-docs"><a href="#new-react-docs" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New React Docs </h2>
<p>Last year, we announced the <a href="https://react.dev/" target="_blank" rel="nofollow noopener noreferrer">beta version</a> of the new React documentation website. The new learning materials teach Hooks first and has new diagrams, illustrations, as well as many interactive examples and challenges. We took a break from that work to focus on the React 18 release, but now that React 18 is out, we’re actively working to finish and ship the new documentation.</p>
<p>We are currently writing a detailed section about effects, as we’ve heard that is one of the more challenging topics for both new and experienced React users. <a href="https://react.dev/learn/synchronizing-with-effects" target="_blank" rel="nofollow noopener noreferrer">Synchronizing with Effects</a> is the first published page in the series, and there are more to come in the following weeks. When we first started writing a detailed section about effects, we’ve realized that many common effect patterns can be simplified by adding a new primitive to React. We’ve shared some initial thoughts on that in the <a href="https://github.com/reactjs/rfcs/pull/220" target="_blank" rel="nofollow noopener noreferrer">useEvent RFC</a>. It is currently in early research, and we are still iterating on the idea. We appreciate the community’s comments on the RFC so far, as well as the <a href="https://github.com/reactjs/reactjs.org/issues/3308" target="_blank" rel="nofollow noopener noreferrer">feedback</a> and contributions to the ongoing documentation rewrite. We’d specifically like to thank <a href="https://github.com/harish-sethuraman" target="_blank" rel="nofollow noopener noreferrer">Harish Kumar</a> for submitting and reviewing many improvements to the new website implementation.</p>
<p><em>Thanks to <a href="https://twitter.com/sophiebits" target="_blank" rel="nofollow noopener noreferrer">Sophie Alpert</a> for reviewing this blog post!</em></p>]]></description><link>https://fr.reactjs.org/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.html</guid><pubDate>Wed, 15 Jun 2022 00:00:00 GMT</pubDate></item><item><title><![CDATA[React v18.0]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>React 18 is now available on npm!</p>
<p>In our last post, we shared step-by-step instructions for <a href="https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html" target="_blank" rel="nofollow noopener noreferrer">upgrading your app to React 18</a>. In this post, we’ll give an overview of what’s new in React 18, and what it means for the future.</p>
<p>Our latest major version includes out-of-the-box improvements like automatic batching, new APIs like startTransition, and streaming server-side rendering with support for Suspense.</p>
<p>Many of the features in React 18 are built on top of our new concurrent renderer, a behind-the-scenes change that unlocks powerful new capabilities. Concurrent React is opt-in — it’s only enabled when you use a concurrent feature — but we think it will have a big impact on the way people build applications.</p>
<p>We’ve spent years researching and developing support for concurrency in React, and we’ve taken extra care to provide a gradual adoption path for existing users. Last summer, <a href="https://reactjs.org/blog/2021/06/08/the-plan-for-react-18.html" target="_blank" rel="nofollow noopener noreferrer">we formed the React 18 Working Group</a> to gather feedback from experts in the community and ensure a smooth upgrade experience for the entire React ecosystem.</p>
<p>In case you missed it, we shared a lot of this vision at React Conf 2021:</p>
<ul>
<li>In <a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa" target="_blank" rel="nofollow noopener noreferrer">the keynote</a>, we explain how React 18 fits into our mission to make it easy for developers to build great user experiences</li>
<li><a href="https://twitter.com/shrutikapoor08" target="_blank" rel="nofollow noopener noreferrer">Shruti Kapoor</a> <a href="https://www.youtube.com/watch?v=ytudH8je5ko&#x26;list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&#x26;index=2" target="_blank" rel="nofollow noopener noreferrer">demonstrated how to use the new features in React 18</a></li>
<li><a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</a> gave us an overview of <a href="https://www.youtube.com/watch?v=pj5N-Khihgc&#x26;list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&#x26;index=3" target="_blank" rel="nofollow noopener noreferrer">streaming server rendering with Suspense</a></li>
</ul>
<p>Below is a full overview of what to expect in this release, starting with Concurrent Rendering.</p>
<p><em>Note for React Native users: React 18 will ship in React Native with the New React Native Architecture. For more information, see the <a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;t=1530s" target="_blank" rel="nofollow noopener noreferrer">React Conf keynote here</a>.</em></p>
<h2 id="what-is-concurrent-react"><a href="#what-is-concurrent-react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>What is Concurrent React? </h2>
<p>The most important addition in React 18 is something we hope you never have to think about: concurrency. We think this is largely true for application developers, though the story may be a bit more complicated for library maintainers.</p>
<p>Concurrency is not a feature, per se. It’s a new behind-the-scenes mechanism that enables React to prepare multiple versions of your UI at the same time. You can think of concurrency as an implementation detail — it’s valuable because of the features that it unlocks. React uses sophisticated techniques in its internal implementation, like priority queues and multiple buffering. But you won’t see those concepts anywhere in our public APIs.</p>
<p>When we design APIs, we try to hide implementation details from developers. As a React developer, you focus on <em>what</em> you want the user experience to look like, and React handles <em>how</em> to deliver that experience. So we don’t expect React developers to know how concurrency works under the hood.</p>
<p>However, Concurrent React is more important than a typical implementation detail — it’s a foundational update to React’s core rendering model. So while it’s not super important to know how concurrency works, it may be worth knowing what it is at a high level.</p>
<p>A key property of Concurrent React is that rendering is interruptible. When you first upgrade to React 18, before adding any concurrent features, updates are rendered the same as in previous versions of React — in a single, uninterrupted, synchronous transaction. With synchronous rendering, once an update starts rendering, nothing can interrupt it until the user can see the result on screen.</p>
<p>In a concurrent render, this is not always the case. React may start rendering an update, pause in the middle, then continue later. It may even abandon an in-progress render altogether. React guarantees that the UI will appear consistent even if a render is interrupted. To do this, it waits to perform DOM mutations until the end, once the entire tree has been evaluated. With this capability, React can prepare new screens in the background without blocking the main thread. This means the UI can respond immediately to user input even if it’s in the middle of a large rendering task, creating a fluid user experience.</p>
<p>Another example is reusable state. Concurrent React can remove sections of the UI from the screen, then add them back later while reusing the previous state. For example, when a user tabs away from a screen and back, React should be able to restore the previous screen in the same state it was in before. In an upcoming minor, we’re planning to add a new component called <code class="gatsby-code-text">&lt;Offscreen></code> that implements this pattern. Similarly, you’ll be able to use Offscreen to prepare new UI in the background so that it’s ready before the user reveals it.</p>
<p>Concurrent rendering is a powerful new tool in React and most of our new features are built to take advantage of it, including Suspense, transitions, and streaming server rendering. But React 18 is just the beginning of what we aim to build on this new foundation.</p>
<h2 id="gradually-adopting-concurrent-features"><a href="#gradually-adopting-concurrent-features" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Gradually Adopting Concurrent Features </h2>
<p>Technically, concurrent rendering is a breaking change. Because concurrent rendering is interruptible, components behave slightly differently when it is enabled.</p>
<p>In our testing, we’ve upgraded thousands of components to React 18. What we’ve found is that nearly all existing components “just work” with concurrent rendering, without any changes. However, some of them may require some additional migration effort. Although the changes are usually small, you’ll still have the ability to make them at your own pace. The new rendering behavior in React 18 is <strong>only enabled in the parts of your app that use new features.</strong></p>
<p>The overall upgrade strategy is to get your application running on React 18 without breaking existing code. Then you can gradually start adding concurrent features at your own pace. You can use <a href="/docs/strict-mode.html"><code class="gatsby-code-text">&lt;StrictMode></code></a> to help surface concurrency-related bugs during development. Strict Mode doesn’t affect production behavior, but during development it will log extra warnings and double-invoke functions that are expected to be idempotent. It won’t catch everything, but it’s effective at preventing the most common types of mistakes.</p>
<p>After you upgrade to React 18, you’ll be able to start using concurrent features immediately. For example, you can use startTransition to navigate between screens without blocking user input. Or useDeferredValue to throttle expensive re-renders.</p>
<p>However, long term, we expect the main way you’ll add concurrency to your app is by using a concurrent-enabled library or framework. In most cases, you won’t interact with concurrent APIs directly. For example, instead of developers calling startTransition whenever they navigate to a new screen, router libraries will automatically wrap navigations in startTransition.</p>
<p>It may take some time for libraries to upgrade to be concurrent compatible. We’ve provided new APIs to make it easier for libraries to take advantage of concurrent features. In the meantime, please be patient with maintainers as we work to gradually migrate the React ecosystem.</p>
<p>For more info, see our previous post: <a href="https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html" target="_blank" rel="nofollow noopener noreferrer">How to upgrade to React 18</a>.</p>
<h2 id="suspense-in-data-frameworks"><a href="#suspense-in-data-frameworks" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Suspense in Data Frameworks </h2>
<p>In React 18, you can start using Suspense for data fetching in opinionated frameworks like Relay, Next.js, Hydrogen, or Remix. Ad hoc data fetching with Suspense is technically possible, but still not recommended as a general strategy.</p>
<p>In the future, we may expose additional primitives that could make it easier to access your data with Suspense, perhaps without the use of an opinionated framework. However, Suspense works best when it’s deeply integrated into your application’s architecture: your router, your data layer, and your server rendering environment. So even long term, we expect that libraries and frameworks will play a crucial role in the React ecosystem.</p>
<p>As in previous versions of React, you can also use Suspense for code splitting on the client with React.lazy. But our vision for Suspense has always been about much more than loading code — the goal is to extend support for Suspense so that eventually, the same declarative Suspense fallback can handle any asynchronous operation (loading code, data, images, etc).</p>
<h2 id="server-components-is-still-in-development"><a href="#server-components-is-still-in-development" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Server Components is Still in Development </h2>
<p><a href="https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html" target="_blank" rel="nofollow noopener noreferrer"><strong>Server Components</strong></a> is an upcoming feature that allows developers to build apps that span the server and client, combining the rich interactivity of client-side apps with the improved performance of traditional server rendering. Server Components is not inherently coupled to Concurrent React, but it’s designed to work best with concurrent features like Suspense and streaming server rendering.</p>
<p>Server Components is still experimental, but we expect to release an initial version in a minor 18.x release. In the meantime, we’re working with frameworks like Next.js, Hydrogen, and Remix to advance the proposal and get it ready for broad adoption.</p>
<h2 id="whats-new-in-react-18"><a href="#whats-new-in-react-18" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>What’s New in React 18 </h2>
<h3 id="new-feature-automatic-batching"><a href="#new-feature-automatic-batching" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New Feature: Automatic Batching </h3>
<p>Batching is when React groups multiple state updates into a single re-render for better performance. Without automatic batching, we only batched updates inside React event handlers. Updates inside of promises, setTimeout, native event handlers, or any other event were not batched in React by default. With automatic batching, these updates will be batched automatically:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Before: only React events were batched.</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token function">setCount</span><span class="token punctuation">(</span><span class="token parameter">c</span> <span class="token operator">=></span> c <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">setFlag</span><span class="token punctuation">(</span><span class="token parameter">f</span> <span class="token operator">=></span> <span class="token operator">!</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React will render twice, once for each state update (no batching)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// After: updates inside of timeouts, promises,</span>
<span class="token comment">// native event handlers or any other event are batched.</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token function">setCount</span><span class="token punctuation">(</span><span class="token parameter">c</span> <span class="token operator">=></span> c <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">setFlag</span><span class="token punctuation">(</span><span class="token parameter">f</span> <span class="token operator">=></span> <span class="token operator">!</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React will only re-render once at the end (that's batching!)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>For more info, see this post for <a href="https://github.com/reactwg/react-18/discussions/21" target="_blank" rel="nofollow noopener noreferrer">Automatic batching for fewer renders in React 18</a>.</p>
<h3 id="new-feature-transitions"><a href="#new-feature-transitions" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New Feature: Transitions </h3>
<p>A transition is a new concept in React to distinguish between urgent and non-urgent updates.</p>
<ul>
<li><strong>Urgent updates</strong> reflect direct interaction, like typing, clicking, pressing, and so on.</li>
<li><strong>Transition updates</strong> transition the UI from one view to another.</li>
</ul>
<p>Urgent updates like typing, clicking, or pressing, need immediate response to match our intuitions about how physical objects behave. Otherwise they feel “wrong”. However, transitions are different because the user doesn’t expect to see every intermediate value on screen.</p>
<p>For example, when you select a filter in a dropdown, you expect the filter button itself to respond immediately when you click. However, the actual results may transition separately. A small delay would be imperceptible and often expected. And if you change the filter again before the results are done rendering, you only care to see the latest results.</p>
<p>Typically, for the best user experience, a single user input should result in both an urgent update and a non-urgent one. You can use startTransition API inside an input event to inform React which updates are urgent and which are “transitions”:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> <span class="token punctuation">{</span>startTransition<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token comment">// Urgent: Show what was typed</span>
<span class="token function">setInputValue</span><span class="token punctuation">(</span>input<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// Mark any state updates inside as transitions</span>
<span class="token function">startTransition</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token comment">// Transition: Show the results</span>
  <span class="token function">setSearchQuery</span><span class="token punctuation">(</span>input<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Updates wrapped in startTransition are handled as non-urgent and will be interrupted if more urgent updates like clicks or key presses come in. If a transition gets interrupted by the user (for example, by typing multiple characters in a row), React will throw out the stale rendering work that wasn’t finished and render only the latest update.</p>
<ul>
<li><code class="gatsby-code-text">useTransition</code>: a hook to start transitions, including a value to track the pending state.</li>
<li><code class="gatsby-code-text">startTransition</code>: a method to start transitions when the hook cannot be used.</li>
</ul>
<p>Transitions will opt in to concurrent rendering, which allows the update to be interrupted. If the content re-suspends, transitions also tell React to continue showing the current content while rendering the transition content in the background (see the <a href="https://github.com/reactjs/rfcs/blob/main/text/0213-suspense-in-react-18.md" target="_blank" rel="nofollow noopener noreferrer">Suspense RFC</a> for more info).</p>
<p><a href="/docs/react-api.html#transitions">See docs for transitions here</a>.</p>
<h3 id="new-suspense-features"><a href="#new-suspense-features" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New Suspense Features </h3>
<p>Suspense lets you declaratively specify the loading state for a part of the component tree if it’s not yet ready to be displayed:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Suspense</span></span> <span class="token attr-name">fallback</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Spinner</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token plain-text">
  </span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Comments</span></span> <span class="token punctuation">/></span></span><span class="token plain-text">
</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Suspense</span></span><span class="token punctuation">></span></span></code></pre></div>
<p>Suspense makes the “UI loading state” a first-class declarative concept in the React programming model. This lets us build higher-level features on top of it.</p>
<p>We introduced a limited version of Suspense several years ago. However, the only supported use case was code splitting with React.lazy, and it wasn’t supported at all when rendering on the server.</p>
<p>In React 18, we’ve added support for Suspense on the server and expanded its capabilities using concurrent rendering features.</p>
<p>Suspense in React 18 works best when combined with the transition API. If you suspend during a transition, React will prevent already-visible content from being replaced by a fallback. Instead, React will delay the render until enough data has loaded to prevent a bad loading state.</p>
<p>For more, see the RFC for <a href="https://github.com/reactjs/rfcs/blob/main/text/0213-suspense-in-react-18.md" target="_blank" rel="nofollow noopener noreferrer">Suspense in React 18</a>.</p>
<h3 id="new-client-and-server-rendering-apis"><a href="#new-client-and-server-rendering-apis" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New Client and Server Rendering APIs </h3>
<p>In this release we took the opportunity to redesign the APIs we expose for rendering on the client and server. These changes allow users to continue using the old APIs in React 17 mode while they upgrade to the new APIs in React 18.</p>
<h4 id="react-dom-client"><a href="#react-dom-client" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Client </h4>
<p>These new APIs are now exported from <code class="gatsby-code-text">react-dom/client</code>:</p>
<ul>
<li><code class="gatsby-code-text">createRoot</code>: New method to create a root to <code class="gatsby-code-text">render</code> or <code class="gatsby-code-text">unmount</code>. Use it instead of <code class="gatsby-code-text">ReactDOM.render</code>. New features in React 18 don’t work without it.</li>
<li><code class="gatsby-code-text">hydrateRoot</code>: New method to hydrate a server rendered application. Use it instead of  <code class="gatsby-code-text">ReactDOM.hydrate</code> in conjunction with the new React DOM Server APIs. New features in React 18 don’t work without it.</li>
</ul>
<p>Both <code class="gatsby-code-text">createRoot</code> and <code class="gatsby-code-text">hydrateRoot</code> accept a new option called <code class="gatsby-code-text">onRecoverableError</code> in case you want to be notified when React recovers from errors during rendering or hydration for logging. By default, React will use <a href="https://developer.mozilla.org/en-US/docs/Web/API/reportError" target="_blank" rel="nofollow noopener noreferrer"><code class="gatsby-code-text">reportError</code></a>, or <code class="gatsby-code-text">console.error</code> in the older browsers.</p>
<p><a href="/docs/react-dom-client.html">See docs for React DOM Client here</a>.</p>
<h4 id="react-dom-server"><a href="#react-dom-server" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Server </h4>
<p>These new APIs are now exported from <code class="gatsby-code-text">react-dom/server</code> and have full support for streaming Suspense on the server:</p>
<ul>
<li><code class="gatsby-code-text">renderToPipeableStream</code>: for streaming in Node environments.</li>
<li><code class="gatsby-code-text">renderToReadableStream</code>: for modern edge runtime environments, such as Deno and Cloudflare workers.</li>
</ul>
<p>The existing <code class="gatsby-code-text">renderToString</code> method keeps working but is discouraged.</p>
<p><a href="/docs/react-dom-server.html">See docs for React DOM Server here</a>.</p>
<h3 id="new-strict-mode-behaviors"><a href="#new-strict-mode-behaviors" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New Strict Mode Behaviors </h3>
<p>In the future, we’d like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same component state as before.</p>
<p>This feature will give React apps better performance out-of-the-box, but requires components to be resilient to effects being mounted and destroyed multiple times. Most effects will work without any changes, but some effects assume they are only mounted or destroyed once.</p>
<p>To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second mount.</p>
<p>Before this change, React would mount the component and create the effects:</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React mounts the component.
  * Layout effects are created.
  * Effects are created.</code></pre></div>
<p>With Strict Mode in React 18, React will simulate unmounting and remounting the component in development mode:</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React mounts the component.
  * Layout effects are created.
  * Effects are created.
* React simulates unmounting the component.
  * Layout effects are destroyed.
  * Effects are destroyed.
* React simulates mounting the component with the previous state.
  * Layout effects are created.
  * Effects are created.</code></pre></div>
<p><a href="/docs/strict-mode.html#ensuring-reusable-state">See docs for ensuring reusable state here</a>.</p>
<h3 id="new-hooks"><a href="#new-hooks" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New Hooks </h3>
<h4 id="useid"><a href="#useid" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>useId </h4>
<p><code class="gatsby-code-text">useId</code> is a new hook for generating unique IDs on both the client and server, while avoiding hydration mismatches. It is primarily useful for component libraries integrating with accessibility APIs that require unique IDs. This solves an issue that already exists in React 17 and below, but it’s even more important in React 18 because of how the new streaming server renderer delivers HTML out-of-order. <a href="/docs/hooks-reference.html#useid">See docs here</a>.</p>
<blockquote>
<p>Note</p>
<p><code class="gatsby-code-text">useId</code> is <strong>not</strong> for generating <a href="/docs/lists-and-keys.html#keys">keys in a list</a>. Keys should be generated from your data.</p>
</blockquote>
<h4 id="usetransition"><a href="#usetransition" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>useTransition </h4>
<p><code class="gatsby-code-text">useTransition</code> and <code class="gatsby-code-text">startTransition</code> let you mark some state updates as not urgent. Other state updates are considered urgent by default. React will allow urgent state updates (for example, updating a text input) to interrupt non-urgent state updates (for example, rendering a list of search results). <a href="/docs/hooks-reference.html#usetransition">See docs here</a></p>
<h4 id="usedeferredvalue"><a href="#usedeferredvalue" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>useDeferredValue </h4>
<p><code class="gatsby-code-text">useDeferredValue</code> lets you defer re-rendering a non-urgent part of the tree. It is similar to debouncing, but has a few advantages compared to it. There is no fixed time delay, so React will attempt the deferred render right after the first render is reflected on the screen. The deferred render is interruptible and doesn’t block user input. <a href="/docs/hooks-reference.html#usedeferredvalue">See docs here</a>.</p>
<h4 id="usesyncexternalstore"><a href="#usesyncexternalstore" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>useSyncExternalStore </h4>
<p><code class="gatsby-code-text">useSyncExternalStore</code> is a new hook that allows external stores to support concurrent reads by forcing updates to the store to be synchronous. It removes the need for useEffect when implementing subscriptions to external data sources, and is recommended for any library that integrates with state external to React. <a href="/docs/hooks-reference.html#usesyncexternalstore">See docs here</a>.</p>
<blockquote>
<p>Note</p>
<p><code class="gatsby-code-text">useSyncExternalStore</code> is intended to be used by libraries, not application code.</p>
</blockquote>
<h4 id="useinsertioneffect"><a href="#useinsertioneffect" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>useInsertionEffect </h4>
<p><code class="gatsby-code-text">useInsertionEffect</code> is a new hook that allows CSS-in-JS libraries to address performance issues of injecting styles in render. Unless you’ve already built a CSS-in-JS library we don’t expect you to ever use this. This hook will run after the DOM is mutated, but before layout effects read the new layout. This solves an issue that already exists in React 17 and below, but is even more important in React 18 because React yields to the browser during concurrent rendering, giving it a chance to recalculate layout. <a href="/docs/hooks-reference.html#useinsertioneffect">See docs here</a>.</p>
<blockquote>
<p>Note</p>
<p><code class="gatsby-code-text">useInsertionEffect</code> is intended to be used by libraries, not application code.</p>
</blockquote>
<h2 id="how-to-upgrade"><a href="#how-to-upgrade" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>How to Upgrade </h2>
<p>See <a href="https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html" target="_blank" rel="nofollow noopener noreferrer">How to Upgrade to React 18</a> for step-by-step instructions and a full list of breaking and notable changes.</p>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li>Add <code class="gatsby-code-text">useTransition</code> and <code class="gatsby-code-text">useDeferredValue</code> to separate urgent updates from transitions. (<a href="https://github.com/facebook/react/pull/10426" target="_blank" rel="nofollow noopener noreferrer">#10426</a>, <a href="https://github.com/facebook/react/pull/10715" target="_blank" rel="nofollow noopener noreferrer">#10715</a>, <a href="https://github.com/facebook/react/pull/15593" target="_blank" rel="nofollow noopener noreferrer">#15593</a>, <a href="https://github.com/facebook/react/pull/15272" target="_blank" rel="nofollow noopener noreferrer">#15272</a>, <a href="https://github.com/facebook/react/pull/15578" target="_blank" rel="nofollow noopener noreferrer">#15578</a>, <a href="https://github.com/facebook/react/pull/15769" target="_blank" rel="nofollow noopener noreferrer">#15769</a>, <a href="https://github.com/facebook/react/pull/17058" target="_blank" rel="nofollow noopener noreferrer">#17058</a>, <a href="https://github.com/facebook/react/pull/18796" target="_blank" rel="nofollow noopener noreferrer">#18796</a>, <a href="https://github.com/facebook/react/pull/19121" target="_blank" rel="nofollow noopener noreferrer">#19121</a>, <a href="https://github.com/facebook/react/pull/19703" target="_blank" rel="nofollow noopener noreferrer">#19703</a>, <a href="https://github.com/facebook/react/pull/19719" target="_blank" rel="nofollow noopener noreferrer">#19719</a>, <a href="https://github.com/facebook/react/pull/19724" target="_blank" rel="nofollow noopener noreferrer">#19724</a>, <a href="https://github.com/facebook/react/pull/20672" target="_blank" rel="nofollow noopener noreferrer">#20672</a>, <a href="https://github.com/facebook/react/pull/20976" target="_blank" rel="nofollow noopener noreferrer">#20976</a> by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>, <a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a>, <a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a>, and <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Add <code class="gatsby-code-text">useId</code> for generating unique IDs. (<a href="https://github.com/facebook/react/pull/17322" target="_blank" rel="nofollow noopener noreferrer">#17322</a>, <a href="https://github.com/facebook/react/pull/18576" target="_blank" rel="nofollow noopener noreferrer">#18576</a>, <a href="https://github.com/facebook/react/pull/22644" target="_blank" rel="nofollow noopener noreferrer">#22644</a>, <a href="https://github.com/facebook/react/pull/22672" target="_blank" rel="nofollow noopener noreferrer">#22672</a>, <a href="https://github.com/facebook/react/pull/21260" target="_blank" rel="nofollow noopener noreferrer">#21260</a> by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>, <a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a>, and <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Add <code class="gatsby-code-text">useSyncExternalStore</code> to help external store libraries integrate with React. (<a href="https://github.com/facebook/react/pull/15022" target="_blank" rel="nofollow noopener noreferrer">#15022</a>, <a href="https://github.com/facebook/react/pull/18000" target="_blank" rel="nofollow noopener noreferrer">#18000</a>, <a href="https://github.com/facebook/react/pull/18771" target="_blank" rel="nofollow noopener noreferrer">#18771</a>, <a href="https://github.com/facebook/react/pull/22211" target="_blank" rel="nofollow noopener noreferrer">#22211</a>, <a href="https://github.com/facebook/react/pull/22292" target="_blank" rel="nofollow noopener noreferrer">#22292</a>, <a href="https://github.com/facebook/react/pull/22239" target="_blank" rel="nofollow noopener noreferrer">#22239</a>, <a href="https://github.com/facebook/react/pull/22347" target="_blank" rel="nofollow noopener noreferrer">#22347</a>, <a href="https://github.com/facebook/react/pull/23150" target="_blank" rel="nofollow noopener noreferrer">#23150</a> by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>, <a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a>, and <a href="https://github.com/drarmstr" target="_blank" rel="nofollow noopener noreferrer">@drarmstr</a>)</li>
<li>Add <code class="gatsby-code-text">startTransition</code> as a version of <code class="gatsby-code-text">useTransition</code> without pending feedback. (<a href="https://github.com/facebook/react/pull/19696" target="_blank" rel="nofollow noopener noreferrer">#19696</a>  by <a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a>)</li>
<li>Add <code class="gatsby-code-text">useInsertionEffect</code> for CSS-in-JS libraries. (<a href="https://github.com/facebook/react/pull/21913" target="_blank" rel="nofollow noopener noreferrer">#21913</a>  by <a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a>)</li>
<li>Make Suspense remount layout effects when content reappears.  (<a href="https://github.com/facebook/react/pull/19322" target="_blank" rel="nofollow noopener noreferrer">#19322</a>, <a href="https://github.com/facebook/react/pull/19374" target="_blank" rel="nofollow noopener noreferrer">#19374</a>, <a href="https://github.com/facebook/react/pull/19523" target="_blank" rel="nofollow noopener noreferrer">#19523</a>, <a href="https://github.com/facebook/react/pull/20625" target="_blank" rel="nofollow noopener noreferrer">#20625</a>, <a href="https://github.com/facebook/react/pull/21079" target="_blank" rel="nofollow noopener noreferrer">#21079</a> by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>, <a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a>, and <a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a>)</li>
<li>Make <code class="gatsby-code-text">&lt;StrictMode></code> re-run effects to check for restorable state. (<a href="https://github.com/facebook/react/pull/19523" target="_blank" rel="nofollow noopener noreferrer">#19523</a> , <a href="https://github.com/facebook/react/pull/21418" target="_blank" rel="nofollow noopener noreferrer">#21418</a>  by <a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> and <a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a>)</li>
<li>Assume Symbols are always available. (<a href="https://github.com/facebook/react/pull/23348" target="_blank" rel="nofollow noopener noreferrer">#23348</a>  by <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Remove <code class="gatsby-code-text">object-assign</code> polyfill. (<a href="https://github.com/facebook/react/pull/23351" target="_blank" rel="nofollow noopener noreferrer">#23351</a>  by <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Remove unsupported <code class="gatsby-code-text">unstable_changedBits</code> API.  (<a href="https://github.com/facebook/react/pull/20953" target="_blank" rel="nofollow noopener noreferrer">#20953</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Allow components to render undefined. (<a href="https://github.com/facebook/react/pull/21869" target="_blank" rel="nofollow noopener noreferrer">#21869</a>  by <a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a>)</li>
<li>Flush <code class="gatsby-code-text">useEffect</code> resulting from discrete events like clicks synchronously. (<a href="https://github.com/facebook/react/pull/21150" target="_blank" rel="nofollow noopener noreferrer">#21150</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Suspense <code class="gatsby-code-text">fallback={undefined}</code> now behaves the same as <code class="gatsby-code-text">null</code> and isn’t ignored. (<a href="https://github.com/facebook/react/pull/21854" target="_blank" rel="nofollow noopener noreferrer">#21854</a>  by <a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a>)</li>
<li>Consider all <code class="gatsby-code-text">lazy()</code> resolving to the same component equivalent. (<a href="https://github.com/facebook/react/pull/20357" target="_blank" rel="nofollow noopener noreferrer">#20357</a>  by <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Don’t patch console during first render. (<a href="https://github.com/facebook/react/pull/22308" target="_blank" rel="nofollow noopener noreferrer">#22308</a>  by <a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a>)</li>
<li>Improve memory usage. (<a href="https://github.com/facebook/react/pull/21039" target="_blank" rel="nofollow noopener noreferrer">#21039</a>  by <a href="https://github.com/bgirard" target="_blank" rel="nofollow noopener noreferrer">@bgirard</a>)</li>
<li>Improve messages if string coercion throws (Temporal.*, Symbol, etc.) (<a href="https://github.com/facebook/react/pull/22064" target="_blank" rel="nofollow noopener noreferrer">#22064</a>  by <a href="https://github.com/justingrant" target="_blank" rel="nofollow noopener noreferrer">@justingrant</a>)</li>
<li>Use <code class="gatsby-code-text">setImmediate</code> when available over <code class="gatsby-code-text">MessageChannel</code>. (<a href="https://github.com/facebook/react/pull/20834" target="_blank" rel="nofollow noopener noreferrer">#20834</a>  by <a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a>)</li>
<li>Fix context failing to propagate inside suspended trees. (<a href="https://github.com/facebook/react/pull/23095" target="_blank" rel="nofollow noopener noreferrer">#23095</a>  by <a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a>)</li>
<li>Fix <code class="gatsby-code-text">useReducer</code> observing incorrect props by removing the eager bailout mechanism. (<a href="https://github.com/facebook/react/pull/22445" target="_blank" rel="nofollow noopener noreferrer">#22445</a>  by <a href="https://github.com/josephsavona" target="_blank" rel="nofollow noopener noreferrer">@josephsavona</a>)</li>
<li>Fix <code class="gatsby-code-text">setState</code> being ignored in Safari when appending iframes. (<a href="https://github.com/facebook/react/pull/23111" target="_blank" rel="nofollow noopener noreferrer">#23111</a>  by <a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a>)</li>
<li>Fix a crash when rendering <code class="gatsby-code-text">ZonedDateTime</code> in the tree. (<a href="https://github.com/facebook/react/pull/20617" target="_blank" rel="nofollow noopener noreferrer">#20617</a>  by <a href="https://github.com/dimaqq" target="_blank" rel="nofollow noopener noreferrer">@dimaqq</a>)</li>
<li>Fix a crash when document is set to <code class="gatsby-code-text">null</code> in tests. (<a href="https://github.com/facebook/react/pull/22695" target="_blank" rel="nofollow noopener noreferrer">#22695</a>  by <a href="https://github.com/SimenB" target="_blank" rel="nofollow noopener noreferrer">@SimenB</a>)</li>
<li>Fix <code class="gatsby-code-text">onLoad</code> not triggering when concurrent features are on. (<a href="https://github.com/facebook/react/pull/23316" target="_blank" rel="nofollow noopener noreferrer">#23316</a>  by <a href="https://github.com/gnoff" target="_blank" rel="nofollow noopener noreferrer">@gnoff</a>)</li>
<li>Fix a warning when a selector returns <code class="gatsby-code-text">NaN</code>.  (<a href="https://github.com/facebook/react/pull/23333" target="_blank" rel="nofollow noopener noreferrer">#23333</a>  by <a href="https://github.com/hachibeeDI" target="_blank" rel="nofollow noopener noreferrer">@hachibeeDI</a>)</li>
<li>Fix a crash when document is set to <code class="gatsby-code-text">null</code> in tests. (<a href="https://github.com/facebook/react/pull/22695" target="_blank" rel="nofollow noopener noreferrer">#22695</a> by <a href="https://github.com/SimenB" target="_blank" rel="nofollow noopener noreferrer">@SimenB</a>)</li>
<li>Fix the generated license header. (<a href="https://github.com/facebook/react/pull/23004" target="_blank" rel="nofollow noopener noreferrer">#23004</a>  by <a href="https://github.com/vitaliemiron" target="_blank" rel="nofollow noopener noreferrer">@vitaliemiron</a>)</li>
<li>Add <code class="gatsby-code-text">package.json</code> as one of the entry points. (<a href="https://github.com/facebook/react/pull/22954" target="_blank" rel="nofollow noopener noreferrer">#22954</a>  by <a href="https://github.com/Jack-Works" target="_blank" rel="nofollow noopener noreferrer">@Jack</a>)</li>
<li>Allow suspending outside a Suspense boundary. (<a href="https://github.com/facebook/react/pull/23267" target="_blank" rel="nofollow noopener noreferrer">#23267</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Log a recoverable error whenever hydration fails. (<a href="https://github.com/facebook/react/pull/23319" target="_blank" rel="nofollow noopener noreferrer">#23319</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
</ul>
<h3 id="react-dom"><a href="#react-dom" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM </h3>
<ul>
<li>Add <code class="gatsby-code-text">createRoot</code> and <code class="gatsby-code-text">hydrateRoot</code>. (<a href="https://github.com/facebook/react/pull/10239" target="_blank" rel="nofollow noopener noreferrer">#10239</a>, <a href="https://github.com/facebook/react/pull/11225" target="_blank" rel="nofollow noopener noreferrer">#11225</a>, <a href="https://github.com/facebook/react/pull/12117" target="_blank" rel="nofollow noopener noreferrer">#12117</a>, <a href="https://github.com/facebook/react/pull/13732" target="_blank" rel="nofollow noopener noreferrer">#13732</a>, <a href="https://github.com/facebook/react/pull/15502" target="_blank" rel="nofollow noopener noreferrer">#15502</a>, <a href="https://github.com/facebook/react/pull/15532" target="_blank" rel="nofollow noopener noreferrer">#15532</a>, <a href="https://github.com/facebook/react/pull/17035" target="_blank" rel="nofollow noopener noreferrer">#17035</a>, <a href="https://github.com/facebook/react/pull/17165" target="_blank" rel="nofollow noopener noreferrer">#17165</a>, <a href="https://github.com/facebook/react/pull/20669" target="_blank" rel="nofollow noopener noreferrer">#20669</a>, <a href="https://github.com/facebook/react/pull/20748" target="_blank" rel="nofollow noopener noreferrer">#20748</a>, <a href="https://github.com/facebook/react/pull/20888" target="_blank" rel="nofollow noopener noreferrer">#20888</a>, <a href="https://github.com/facebook/react/pull/21072" target="_blank" rel="nofollow noopener noreferrer">#21072</a>, <a href="https://github.com/facebook/react/pull/21417" target="_blank" rel="nofollow noopener noreferrer">#21417</a>, <a href="https://github.com/facebook/react/pull/21652" target="_blank" rel="nofollow noopener noreferrer">#21652</a>, <a href="https://github.com/facebook/react/pull/21687" target="_blank" rel="nofollow noopener noreferrer">#21687</a>, <a href="https://github.com/facebook/react/pull/23207" target="_blank" rel="nofollow noopener noreferrer">#23207</a>, <a href="https://github.com/facebook/react/pull/23385" target="_blank" rel="nofollow noopener noreferrer">#23385</a> by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>, <a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a>, <a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a>, <a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a>, <a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a>, <a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a>, and <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Add selective hydration. (<a href="https://github.com/facebook/react/pull/14717" target="_blank" rel="nofollow noopener noreferrer">#14717</a>, <a href="https://github.com/facebook/react/pull/14884" target="_blank" rel="nofollow noopener noreferrer">#14884</a>, <a href="https://github.com/facebook/react/pull/16725" target="_blank" rel="nofollow noopener noreferrer">#16725</a>, <a href="https://github.com/facebook/react/pull/16880" target="_blank" rel="nofollow noopener noreferrer">#16880</a>, <a href="https://github.com/facebook/react/pull/17004" target="_blank" rel="nofollow noopener noreferrer">#17004</a>, <a href="https://github.com/facebook/react/pull/22416" target="_blank" rel="nofollow noopener noreferrer">#22416</a>, <a href="https://github.com/facebook/react/pull/22629" target="_blank" rel="nofollow noopener noreferrer">#22629</a>, <a href="https://github.com/facebook/react/pull/22448" target="_blank" rel="nofollow noopener noreferrer">#22448</a>, <a href="https://github.com/facebook/react/pull/22856" target="_blank" rel="nofollow noopener noreferrer">#22856</a>, <a href="https://github.com/facebook/react/pull/23176" target="_blank" rel="nofollow noopener noreferrer">#23176</a> by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>, <a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a>, <a href="https://github.com/salazarm" target="_blank" rel="nofollow noopener noreferrer">@salazarm</a>, and <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Add <code class="gatsby-code-text">aria-description</code> to the list of known ARIA attributes. (<a href="https://github.com/facebook/react/pull/22142" target="_blank" rel="nofollow noopener noreferrer">#22142</a>  by <a href="https://github.com/mahyareb" target="_blank" rel="nofollow noopener noreferrer">@mahyareb</a>)</li>
<li>Add <code class="gatsby-code-text">onResize</code> event to video elements. (<a href="https://github.com/facebook/react/pull/21973" target="_blank" rel="nofollow noopener noreferrer">#21973</a>  by <a href="https://github.com/rileyjshaw" target="_blank" rel="nofollow noopener noreferrer">@rileyjshaw</a>)</li>
<li>Add <code class="gatsby-code-text">imageSizes</code> and <code class="gatsby-code-text">imageSrcSet</code> to known props. (<a href="https://github.com/facebook/react/pull/22550" target="_blank" rel="nofollow noopener noreferrer">#22550</a>  by <a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a>)</li>
<li>Allow non-string <code class="gatsby-code-text">&lt;option></code> children if <code class="gatsby-code-text">value</code> is provided.  (<a href="https://github.com/facebook/react/pull/21431" target="_blank" rel="nofollow noopener noreferrer">#21431</a>  by <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Fix <code class="gatsby-code-text">aspectRatio</code> style not being applied. (<a href="https://github.com/facebook/react/pull/21100" target="_blank" rel="nofollow noopener noreferrer">#21100</a>  by <a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a>)</li>
<li>Warn if <code class="gatsby-code-text">renderSubtreeIntoContainer</code> is called. (<a href="https://github.com/facebook/react/pull/23355" target="_blank" rel="nofollow noopener noreferrer">#23355</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
</ul>
<h3 id="react-dom-server-1"><a href="#react-dom-server-1" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Server </h3>
<ul>
<li>Add the new streaming renderer. (<a href="https://github.com/facebook/react/pull/14144" target="_blank" rel="nofollow noopener noreferrer">#14144</a>, <a href="https://github.com/facebook/react/pull/20970" target="_blank" rel="nofollow noopener noreferrer">#20970</a>, <a href="https://github.com/facebook/react/pull/21056" target="_blank" rel="nofollow noopener noreferrer">#21056</a>, <a href="https://github.com/facebook/react/pull/21255" target="_blank" rel="nofollow noopener noreferrer">#21255</a>, <a href="https://github.com/facebook/react/pull/21200" target="_blank" rel="nofollow noopener noreferrer">#21200</a>, <a href="https://github.com/facebook/react/pull/21257" target="_blank" rel="nofollow noopener noreferrer">#21257</a>, <a href="https://github.com/facebook/react/pull/21276" target="_blank" rel="nofollow noopener noreferrer">#21276</a>, <a href="https://github.com/facebook/react/pull/22443" target="_blank" rel="nofollow noopener noreferrer">#22443</a>, <a href="https://github.com/facebook/react/pull/22450" target="_blank" rel="nofollow noopener noreferrer">#22450</a>, <a href="https://github.com/facebook/react/pull/23247" target="_blank" rel="nofollow noopener noreferrer">#23247</a>, <a href="https://github.com/facebook/react/pull/24025" target="_blank" rel="nofollow noopener noreferrer">#24025</a>, <a href="https://github.com/facebook/react/pull/24030" target="_blank" rel="nofollow noopener noreferrer">#24030</a> by <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Fix context providers in SSR when handling multiple requests. (<a href="https://github.com/facebook/react/pull/23171" target="_blank" rel="nofollow noopener noreferrer">#23171</a>  by <a href="https://github.com/frandiox" target="_blank" rel="nofollow noopener noreferrer">@frandiox</a>)</li>
<li>Revert to client render on text mismatch. (<a href="https://github.com/facebook/react/pull/23354" target="_blank" rel="nofollow noopener noreferrer">#23354</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Deprecate <code class="gatsby-code-text">renderToNodeStream</code>. (<a href="https://github.com/facebook/react/pull/23359" target="_blank" rel="nofollow noopener noreferrer">#23359</a>  by <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
<li>Fix a spurious error log in the new server renderer. (<a href="https://github.com/facebook/react/pull/24043" target="_blank" rel="nofollow noopener noreferrer">#24043</a>  by <a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a>)</li>
<li>Fix a bug in the new server renderer. (<a href="https://github.com/facebook/react/pull/22617" target="_blank" rel="nofollow noopener noreferrer">#22617</a>  by <a href="https://github.com/shuding" target="_blank" rel="nofollow noopener noreferrer">@shuding</a>)</li>
<li>Ignore function and symbol values inside custom elements on the server. (<a href="https://github.com/facebook/react/pull/21157" target="_blank" rel="nofollow noopener noreferrer">#21157</a>  by <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a>)</li>
</ul>
<h3 id="react-dom-test-utils"><a href="#react-dom-test-utils" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Test Utils </h3>
<ul>
<li>Throw when <code class="gatsby-code-text">act</code> is used in production. (<a href="https://github.com/facebook/react/pull/21686" target="_blank" rel="nofollow noopener noreferrer">#21686</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Support disabling spurious act warnings with <code class="gatsby-code-text">global.IS_REACT_ACT_ENVIRONMENT</code>. (<a href="https://github.com/facebook/react/pull/22561" target="_blank" rel="nofollow noopener noreferrer">#22561</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Expand act warning to cover all APIs that might schedule React work. (<a href="https://github.com/facebook/react/pull/22607" target="_blank" rel="nofollow noopener noreferrer">#22607</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Make <code class="gatsby-code-text">act</code> batch updates. (<a href="https://github.com/facebook/react/pull/21797" target="_blank" rel="nofollow noopener noreferrer">#21797</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
<li>Remove warning for dangling passive effects. (<a href="https://github.com/facebook/react/pull/22609" target="_blank" rel="nofollow noopener noreferrer">#22609</a>  by <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a>)</li>
</ul>
<h3 id="react-refresh"><a href="#react-refresh" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Refresh </h3>
<ul>
<li>Track late-mounted roots in Fast Refresh. (<a href="https://github.com/facebook/react/pull/22740" target="_blank" rel="nofollow noopener noreferrer">#22740</a>  by <a href="https://github.com/anc95" target="_blank" rel="nofollow noopener noreferrer">@anc95</a>)</li>
<li>Add <code class="gatsby-code-text">exports</code> field to <code class="gatsby-code-text">package.json</code>. (<a href="https://github.com/facebook/react/pull/23087" target="_blank" rel="nofollow noopener noreferrer">#23087</a>  by <a href="https://github.com/otakustay" target="_blank" rel="nofollow noopener noreferrer">@otakustay</a>)</li>
</ul>
<h3 id="server-components-experimental"><a href="#server-components-experimental" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Server Components (Experimental) </h3>
<ul>
<li>Add Server Context support. (<a href="https://github.com/facebook/react/pull/23244" target="_blank" rel="nofollow noopener noreferrer">#23244</a>  by <a href="https://github.com/salazarm" target="_blank" rel="nofollow noopener noreferrer">@salazarm</a>)</li>
<li>Add <code class="gatsby-code-text">lazy</code> support. (<a href="https://github.com/facebook/react/pull/24068" target="_blank" rel="nofollow noopener noreferrer">#24068</a>  by <a href="https://github.com/gnoff" target="_blank" rel="nofollow noopener noreferrer">@gnoff</a>)</li>
<li>Update webpack plugin for webpack 5 (<a href="https://github.com/facebook/react/pull/22739" target="_blank" rel="nofollow noopener noreferrer">#22739</a>  by <a href="https://github.com/michenly" target="_blank" rel="nofollow noopener noreferrer">@michenly</a>)</li>
<li>Fix a mistake in the Node loader. (<a href="https://github.com/facebook/react/pull/22537" target="_blank" rel="nofollow noopener noreferrer">#22537</a>  by <a href="https://github.com/btea" target="_blank" rel="nofollow noopener noreferrer">@btea</a>)</li>
<li>Use <code class="gatsby-code-text">globalThis</code> instead of <code class="gatsby-code-text">window</code> for edge environments. (<a href="https://github.com/facebook/react/pull/22777" target="_blank" rel="nofollow noopener noreferrer">#22777</a>  by <a href="https://github.com/huozhi" target="_blank" rel="nofollow noopener noreferrer">@huozhi</a>)</li>
</ul>]]></description><link>https://fr.reactjs.org/blog/2022/03/29/react-v18.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2022/03/29/react-v18.html</guid><pubDate>Tue, 29 Mar 2022 00:00:00 GMT</pubDate></item><item><title><![CDATA[How to Upgrade to React 18]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>As we shared in the <a href="/blog/2022/03/29/react-v18.html">release post</a>, React 18 introduces features powered by our new concurrent renderer, with a gradual adoption strategy for existing applications. In this post, we will guide you through the steps for upgrading to React 18.</p>
<p>Please <a href="https://github.com/facebook/react/issues/new/choose" target="_blank" rel="nofollow noopener noreferrer">report any issues</a> you encounter while upgrading to React 18.</p>
<p><em>Note for React Native users: React 18 will ship in a future version of React Native. This is because React 18 relies on the New React Native Architecture to benefit from the new capabilities presented in this blogpost. For more information, see the <a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;t=1530s" target="_blank" rel="nofollow noopener noreferrer">React Conf keynote here</a>.</em></p>
<h2 id="installing"><a href="#installing" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Installing </h2>
<p>To install the latest version of React:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">npm</span> <span class="token function">install</span> react react-dom</code></pre></div>
<p>Or if you’re using yarn:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">yarn</span> <span class="token function">add</span> react react-dom</code></pre></div>
<h2 id="updates-to-client-rendering-apis"><a href="#updates-to-client-rendering-apis" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Updates to Client Rendering APIs </h2>
<p>When you first install React 18, you will see a warning in the console:</p>
<blockquote>
<p>ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it’s running React 17. Learn more: <a href="https://reactjs.org/link/switch-to-createroot" target="_blank" rel="nofollow noopener noreferrer">https://reactjs.org/link/switch-to-createroot</a></p>
</blockquote>
<p>React 18 introduces a new root API which provides better ergonomics for managing roots. The new root API also enables the new concurrent renderer, which allows you to opt-into concurrent features.</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Before</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> render <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'app'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token attr-name">tab</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>home<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> container<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// After</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> createRoot <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react-dom/client'</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'app'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> root <span class="token operator">=</span> <span class="token function">createRoot</span><span class="token punctuation">(</span>container<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// createRoot(container!) if you use TypeScript</span>
root<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token attr-name">tab</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>home<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>We’ve also changed <code class="gatsby-code-text">unmountComponentAtNode</code> to <code class="gatsby-code-text">root.unmount</code>:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Before</span>
<span class="token function">unmountComponentAtNode</span><span class="token punctuation">(</span>container<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// After</span>
root<span class="token punctuation">.</span><span class="token function">unmount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>We’ve also removed the callback from render, since it usually does not have the expected result when using Suspense:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Before</span>
<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'app'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token attr-name">tab</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>home<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> container<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'rendered'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// After</span>
<span class="token keyword">function</span> <span class="token function">AppWithCallbackAfterRender</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">useEffect</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'rendered'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token attr-name">tab</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>home<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
<span class="token punctuation">}</span>

<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'app'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> root <span class="token operator">=</span> <span class="token function">createRoot</span><span class="token punctuation">(</span>container<span class="token punctuation">)</span><span class="token punctuation">;</span>
root<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">AppWithCallbackAfterRender</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<blockquote>
<p>Note:</p>
<p>There is no one-to-one replacement for the old render callback API — it depends on your use case. See the working group post for <a href="https://github.com/reactwg/react-18/discussions/5" target="_blank" rel="nofollow noopener noreferrer">Replacing render with createRoot</a> for more information.</p>
</blockquote>
<p>Finally, if your app uses server-side rendering with hydration, upgrade <code class="gatsby-code-text">hydrate</code> to <code class="gatsby-code-text">hydrateRoot</code>:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Before</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> hydrate <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'app'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">hydrate</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token attr-name">tab</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>home<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> container<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// After</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> hydrateRoot <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react-dom/client'</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'app'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> root <span class="token operator">=</span> <span class="token function">hydrateRoot</span><span class="token punctuation">(</span>container<span class="token punctuation">,</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token attr-name">tab</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>home<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// Unlike with createRoot, you don't need a separate root.render() call here.</span></code></pre></div>
<p>For more information, see the <a href="https://github.com/reactwg/react-18/discussions/5" target="_blank" rel="nofollow noopener noreferrer">working group discussion here</a>.</p>
<blockquote>
<p>Note</p>
<p><strong>If your app doesn’t work after upgrading, check whether it’s wrapped in <code class="gatsby-code-text">&lt;StrictMode></code>.</strong> <a href="#updates-to-strict-mode">Strict Mode has gotten stricter in React 18</a>, and not all your components may be resilient to the new checks it adds in development mode. If removing Strict Mode fixes your app, you can remove it during the upgrade, and then add it back (either at the top or for a part of the tree) after you fix the issues that it’s pointing out.</p>
</blockquote>
<h2 id="updates-to-server-rendering-apis"><a href="#updates-to-server-rendering-apis" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Updates to Server Rendering APIs </h2>
<p>In this release, we’re revamping our <code class="gatsby-code-text">react-dom/server</code> APIs to fully support Suspense on the server and Streaming SSR. As part of these changes, we’re deprecating the old Node streaming API, which does not support incremental Suspense streaming on the server.</p>
<p>Using this API will now warn:</p>
<ul>
<li><code class="gatsby-code-text">renderToNodeStream</code>: <strong>Deprecated ⛔️️</strong></li>
</ul>
<p>Instead, for streaming in Node environments, use:</p>
<ul>
<li><code class="gatsby-code-text">renderToPipeableStream</code>: <strong>New ✨</strong></li>
</ul>
<p>We’re also introducing a new API to support streaming SSR with Suspense for modern edge runtime environments, such as Deno and Cloudflare workers:</p>
<ul>
<li><code class="gatsby-code-text">renderToReadableStream</code>: <strong>New ✨</strong></li>
</ul>
<p>The following APIs will continue working, but with limited support for Suspense:</p>
<ul>
<li><code class="gatsby-code-text">renderToString</code>: <strong>Limited</strong> ⚠️</li>
<li><code class="gatsby-code-text">renderToStaticMarkup</code>: <strong>Limited</strong> ⚠️</li>
</ul>
<p>Finally, this API will continue to work for rendering e-mails:</p>
<ul>
<li><code class="gatsby-code-text">renderToStaticNodeStream</code></li>
</ul>
<p>For more information on the changes to server rendering APIs, see the working group post on <a href="https://github.com/reactwg/react-18/discussions/22" target="_blank" rel="nofollow noopener noreferrer">Upgrading to React 18 on the server</a>, a <a href="https://github.com/reactwg/react-18/discussions/37" target="_blank" rel="nofollow noopener noreferrer">deep dive on the new Suspense SSR Architecture</a>, and <a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person’s</a> talk on <a href="https://www.youtube.com/watch?v=pj5N-Khihgc" target="_blank" rel="nofollow noopener noreferrer">Streaming Server Rendering with Suspense</a> at React Conf 2021.</p>
<h2 id="updates-to-typescript-definitions"><a href="#updates-to-typescript-definitions" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Updates to TypeScript definitions</h2>
<p>If your project uses TypeScript, you will need to update your <code class="gatsby-code-text">@types/react</code> and <code class="gatsby-code-text">@types/react-dom</code> dependencies to the latest versions. The new types are safer and catch issues that used to be ignored by the type checker. The most notable change is that the <code class="gatsby-code-text">children</code> prop now needs to be listed explicitly when defining props, for example:</p>
<div class="gatsby-highlight has-highlighted-lines" data-language="typescript"><pre class="gatsby-code-typescript"><code class="gatsby-code-typescript"><span class="token keyword">interface</span> <span class="token class-name">MyButtonProps</span> <span class="token punctuation">{</span>
  color<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span>
<span class="gatsby-highlight-code-line">  children<span class="token operator">?</span><span class="token operator">:</span> React<span class="token punctuation">.</span>ReactNode<span class="token punctuation">;</span></span><span class="token punctuation">}</span></code></pre></div>
<p>See the <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210" target="_blank" rel="nofollow noopener noreferrer">React 18 typings pull request</a> for a full list of type-only changes. It links to example fixes in library types so you can see how to adjust your code. You can use the <a href="https://github.com/eps1lon/types-react-codemod" target="_blank" rel="nofollow noopener noreferrer">automated migration script</a> to help port your application code to the new and safer typings faster.</p>
<p>If you find a bug in the typings, please <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/new?category=issues-with-a-types-package" target="_blank" rel="nofollow noopener noreferrer">file an issue</a> in the DefinitelyTyped repo.</p>
<h2 id="automatic-batching"><a href="#automatic-batching" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Automatic Batching </h2>
<p>React 18 adds out-of-the-box performance improvements by doing more batching by default. Batching is when React groups multiple state updates into a single re-render for better performance. Before React 18, we only batched updates inside React event handlers. Updates inside of promises, setTimeout, native event handlers, or any other event were not batched in React by default:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Before React 18 only React events were batched</span>

<span class="token keyword">function</span> <span class="token function">handleClick</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">setCount</span><span class="token punctuation">(</span><span class="token parameter">c</span> <span class="token operator">=></span> c <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">setFlag</span><span class="token punctuation">(</span><span class="token parameter">f</span> <span class="token operator">=></span> <span class="token operator">!</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React will only re-render once at the end (that's batching!)</span>
<span class="token punctuation">}</span>

<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token function">setCount</span><span class="token punctuation">(</span><span class="token parameter">c</span> <span class="token operator">=></span> c <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">setFlag</span><span class="token punctuation">(</span><span class="token parameter">f</span> <span class="token operator">=></span> <span class="token operator">!</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React will render twice, once for each state update (no batching)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Starting in React 18 with <code class="gatsby-code-text">createRoot</code>, all updates will be automatically batched, no matter where they originate from. This means that updates inside of timeouts, promises, native event handlers or any other event will batch the same way as updates inside of React events:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// After React 18 updates inside of timeouts, promises,</span>
<span class="token comment">// native event handlers or any other event are batched.</span>

<span class="token keyword">function</span> <span class="token function">handleClick</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">setCount</span><span class="token punctuation">(</span><span class="token parameter">c</span> <span class="token operator">=></span> c <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">setFlag</span><span class="token punctuation">(</span><span class="token parameter">f</span> <span class="token operator">=></span> <span class="token operator">!</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React will only re-render once at the end (that's batching!)</span>
<span class="token punctuation">}</span>

<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token function">setCount</span><span class="token punctuation">(</span><span class="token parameter">c</span> <span class="token operator">=></span> c <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">setFlag</span><span class="token punctuation">(</span><span class="token parameter">f</span> <span class="token operator">=></span> <span class="token operator">!</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React will only re-render once at the end (that's batching!)</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>This is a breaking change, but we expect this to result in less work rendering, and therefore better performance in your applications. To opt-out of automatic batching, you can use <code class="gatsby-code-text">flushSync</code>:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> <span class="token punctuation">{</span> flushSync <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">handleClick</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">flushSync</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
    <span class="token function">setCounter</span><span class="token punctuation">(</span><span class="token parameter">c</span> <span class="token operator">=></span> c <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React has updated the DOM by now</span>
  <span class="token function">flushSync</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
    <span class="token function">setFlag</span><span class="token punctuation">(</span><span class="token parameter">f</span> <span class="token operator">=></span> <span class="token operator">!</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// React has updated the DOM by now</span>
<span class="token punctuation">}</span></code></pre></div>
<p>For more information, see the <a href="https://github.com/reactwg/react-18/discussions/21" target="_blank" rel="nofollow noopener noreferrer">Automatic batching deep dive</a>.</p>
<h2 id="new-apis-for-libraries"><a href="#new-apis-for-libraries" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New APIs for Libraries </h2>
<p>In the React 18 Working Group we worked with library maintainers to create new APIs needed to support concurrent rendering for use cases specific to their use case in areas like styles, and external stores. To support React 18, some libraries may need to switch to one of the following APIs:</p>
<ul>
<li><code class="gatsby-code-text">useSyncExternalStore</code> is a new hook that allows external stores to support concurrent reads by forcing updates to the store to be synchronous. This new API is recommended for any library that integrates with state external to React. For more information, see the <a href="https://github.com/reactwg/react-18/discussions/70" target="_blank" rel="nofollow noopener noreferrer">useSyncExternalStore overview post</a> and <a href="https://github.com/reactwg/react-18/discussions/86" target="_blank" rel="nofollow noopener noreferrer">useSyncExternalStore API details</a>.</li>
<li><code class="gatsby-code-text">useInsertionEffect</code> is a new hook that allows CSS-in-JS libraries to address performance issues of injecting styles in render. Unless you’ve already built a CSS-in-JS library we don’t expect you to ever use this. This hook will run after the DOM is mutated, but before layout effects read the new layout. This solves an issue that already exists in React 17 and below, but is even more important in React 18 because React yields to the browser during concurrent rendering, giving it a chance to recalculate layout. For more information, see the <a href="https://github.com/reactwg/react-18/discussions/110" target="_blank" rel="nofollow noopener noreferrer">Library Upgrade Guide for <code class="gatsby-code-text">&lt;style></code></a>.</li>
</ul>
<p>React 18 also introduces new APIs for concurrent rendering such as <code class="gatsby-code-text">startTransition</code>, <code class="gatsby-code-text">useDeferredValue</code> and <code class="gatsby-code-text">useId</code>, which we share more about in the <a href="/blog/2022/03/29/react-v18.html">release post</a>.</p>
<h2 id="updates-to-strict-mode"><a href="#updates-to-strict-mode" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Updates to Strict Mode </h2>
<p>In the future, we’d like to add a feature that allows React to add and remove sections of the UI while preserving state. For example, when a user tabs away from a screen and back, React should be able to immediately show the previous screen. To do this, React would unmount and remount trees using the same component state as before.</p>
<p>This feature will give React better performance out-of-the-box, but requires components to be resilient to effects being mounted and destroyed multiple times. Most effects will work without any changes, but some effects assume they are only mounted or destroyed once.</p>
<p>To help surface these issues, React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second mount.</p>
<p>Before this change, React would mount the component and create the effects:</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React mounts the component.
    * Layout effects are created.
    * Effect effects are created.</code></pre></div>
<p>With Strict Mode in React 18, React will simulate unmounting and remounting the component in development mode:</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React mounts the component.
    * Layout effects are created.
    * Effect effects are created.
* React simulates unmounting the component.
    * Layout effects are destroyed.
    * Effects are destroyed.
* React simulates mounting the component with the previous state.
    * Layout effect setup code runs
    * Effect setup code runs</code></pre></div>
<p>For more information, see the Working Group posts for <a href="https://github.com/reactwg/react-18/discussions/19" target="_blank" rel="nofollow noopener noreferrer">Adding Reusable State to StrictMode</a> and <a href="https://github.com/reactwg/react-18/discussions/18" target="_blank" rel="nofollow noopener noreferrer">How to support Reusable State in Effects</a>.</p>
<h2 id="configuring-your-testing-environment"><a href="#configuring-your-testing-environment" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Configuring Your Testing Environment </h2>
<p>When you first update your tests to use <code class="gatsby-code-text">createRoot</code>, you may see this warning in your test console:</p>
<blockquote>
<p>The current testing environment is not configured to support act(…)</p>
</blockquote>
<p>To fix this, set <code class="gatsby-code-text">globalThis.IS_REACT_ACT_ENVIRONMENT</code> to <code class="gatsby-code-text">true</code> before running your test:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// In your test setup file</span>
globalThis<span class="token punctuation">.</span><span class="token constant">IS_REACT_ACT_ENVIRONMENT</span> <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span></code></pre></div>
<p>The purpose of the flag is to tell React that it’s running in a unit test-like environment. React will log helpful warnings if you forget to wrap an update with <code class="gatsby-code-text">act</code>.</p>
<p>You can also set the flag to <code class="gatsby-code-text">false</code> to tell React that <code class="gatsby-code-text">act</code> isn’t needed. This can be useful for end-to-end tests that simulate a full browser environment.</p>
<p>Eventually, we expect testing libraries will configure this for you automatically. For example, the <a href="https://github.com/testing-library/react-testing-library/issues/509#issuecomment-917989936" target="_blank" rel="nofollow noopener noreferrer">next version of React Testing Library has built-in support for React 18</a> without any additional configuration.</p>
<p><a href="https://github.com/reactwg/react-18/discussions/102" target="_blank" rel="nofollow noopener noreferrer">More background on the <code class="gatsby-code-text">act</code> testing API and related changes</a> is available in the working group.</p>
<h2 id="dropping-support-for-internet-explorer"><a href="#dropping-support-for-internet-explorer" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Dropping Support for Internet Explorer </h2>
<p>In this release, React is dropping support for Internet Explorer, which is <a href="https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge" target="_blank" rel="nofollow noopener noreferrer">going out of support on June 15, 2022</a>. We’re making this change now because new features introduced in React 18 are built using modern browser features such as microtasks which cannot be adequately polyfilled in IE.</p>
<p>If you need to support Internet Explorer we recommend you stay with React 17.</p>
<h2 id="deprecations"><a href="#deprecations" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Deprecations </h2>
<ul>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.render</code> has been deprecated. Using it will warn and run your app in React 17 mode.</li>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.hydrate</code> has been deprecated. Using it will warn and run your app in React 17 mode.</li>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.unmountComponentAtNode</code> has been deprecated.</li>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.renderSubtreeIntoContainer</code> has been deprecated.</li>
<li><code class="gatsby-code-text">react-dom/server</code>: <code class="gatsby-code-text">ReactDOMServer.renderToNodeStream</code> has been deprecated.</li>
</ul>
<h2 id="other-breaking-changes"><a href="#other-breaking-changes" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Other Breaking Changes </h2>
<ul>
<li><strong>Consistent useEffect timing</strong>: React now always synchronously flushes effect functions if the update was triggered during a discrete user input event such as a click or a keydown event. Previously, the behavior wasn’t always predictable or consistent.</li>
<li><strong>Stricter hydration errors</strong>: Hydration mismatches due to missing or extra text content are now treated like errors instead of warnings. React will no longer attempt to “patch up” individual nodes by inserting or deleting a node on the client in an attempt to match the server markup, and will revert to client rendering up to the closest <code class="gatsby-code-text">&lt;Suspense></code> boundary in the tree. This ensures the hydrated tree is consistent and avoids potential privacy and security holes that can be caused by hydration mismatches.</li>
<li><strong>Suspense trees are always consistent:</strong> If a component suspends before it’s fully added to the tree, React will not add it to the tree in an incomplete state or fire its effects. Instead, React will throw away the new tree completely, wait for the asynchronous operation to finish, and then retry rendering again from scratch. React will render the retry attempt concurrently, and without blocking the browser.</li>
<li><strong>Layout Effects with Suspense</strong>: When a tree re-suspends and reverts to a fallback, React will now clean up layout effects, and then re-create them when the content inside the boundary is shown again. This fixes an issue which prevented component libraries from correctly measuring layout when used with Suspense.</li>
<li><strong>New JS Environment Requirements</strong>: React now depends on modern browsers features including <code class="gatsby-code-text">Promise</code>, <code class="gatsby-code-text">Symbol</code>, and <code class="gatsby-code-text">Object.assign</code>. If you support older browsers and devices such as Internet Explorer which do not provide modern browser features natively or have non-compliant implementations, consider including a global polyfill in your bundled application.</li>
</ul>
<h2 id="other-notable-changes"><a href="#other-notable-changes" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Other Notable Changes </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li><strong>Components can now render <code class="gatsby-code-text">undefined</code>:</strong> React no longer warns if you return <code class="gatsby-code-text">undefined</code> from a component. This makes the allowed component return values consistent with values that are allowed in the middle of a component tree. We suggest to use a linter to prevent mistakes like forgetting a <code class="gatsby-code-text">return</code> statement before JSX.</li>
<li><strong>In tests, <code class="gatsby-code-text">act</code> warnings are now opt-in:</strong> If you’re running end-to-end tests, the <code class="gatsby-code-text">act</code> warnings are unnecessary. We’ve introduced an <a href="https://github.com/reactwg/react-18/discussions/102" target="_blank" rel="nofollow noopener noreferrer">opt-in</a> mechanism so you can enable them only for unit tests where they are useful and beneficial.</li>
<li><strong>No warning about <code class="gatsby-code-text">setState</code> on unmounted components:</strong> Previously, React warned about memory leaks when you call <code class="gatsby-code-text">setState</code> on an unmounted component. This warning was added for subscriptions, but people primarily run into it in scenarios where setting state is fine, and workarounds make the code worse. We’ve <a href="https://github.com/facebook/react/pull/22114" target="_blank" rel="nofollow noopener noreferrer">removed</a> this warning.</li>
<li><strong>No suppression of console logs:</strong> When you use Strict Mode, React renders each component twice to help you find unexpected side effects. In React 17, we’ve suppressed console logs for one of the two renders to make the logs easier to read. In response to <a href="https://github.com/facebook/react/issues/21783" target="_blank" rel="nofollow noopener noreferrer">community feedback</a> about this being confusing, we’ve removed the suppression. Instead, if you have React DevTools installed, the second log’s renders will be displayed in grey, and there will be an option (off by default) to suppress them completely.</li>
<li><strong>Improved memory usage:</strong> React now cleans up more internal fields on unmount, making the impact from unfixed memory leaks that may exist in your application code less severe.</li>
</ul>
<h3 id="react-dom-server"><a href="#react-dom-server" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Server </h3>
<ul>
<li><strong><code class="gatsby-code-text">renderToString</code>:</strong> Will no longer error when suspending on the server. Instead, it will emit the fallback HTML for the closest <code class="gatsby-code-text">&lt;Suspense></code> boundary and then retry rendering the same content on the client. It is still recommended that you switch to a streaming API like <code class="gatsby-code-text">renderToPipeableStream</code> or <code class="gatsby-code-text">renderToReadableStream</code> instead.</li>
<li><strong><code class="gatsby-code-text">renderToStaticMarkup</code>:</strong> Will no longer error when suspending on the server. Instead, it will emit the fallback HTML for the closest <code class="gatsby-code-text">&lt;Suspense></code> boundary.</li>
</ul>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<p>You can view the <a href="https://github.com/facebook/react/blob/main/CHANGELOG.md" target="_blank" rel="nofollow noopener noreferrer">full changelog here</a>.</p>]]></description><link>https://fr.reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html</guid><pubDate>Tue, 08 Mar 2022 00:00:00 GMT</pubDate></item><item><title><![CDATA[React Conf 2021 Recap]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Last week we hosted our 6th React Conf.  In previous years, we’ve used the React Conf stage to deliver industry changing announcements such as <a href="https://engineering.fb.com/2015/03/26/android/react-native-bringing-modern-web-techniques-to-mobile/" target="_blank" rel="nofollow noopener noreferrer"><em>React Native</em></a> and <a href="https://reactjs.org/docs/hooks-intro.html" target="_blank" rel="nofollow noopener noreferrer"><em>React Hooks</em></a>. This year, we shared our multi-platform vision for React, starting with the release of React 18 and gradual adoption of concurrent features.</p>
<p>This was the first time React Conf was hosted online, and it was streamed for free, translated to 8 different languages. Participants from all over the world joined our conference Discord and the replay event for accessibility in all timezones. Over 50,000 people registered, with over 60,000 views of 19 talks, and 5,000 participants in Discord across both events.</p>
<p>All the talks are <a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa" target="_blank" rel="nofollow noopener noreferrer">available to stream online</a>.</p>
<p>Here’s a summary of what was shared on stage:</p>
<h2 id="react-18-and-concurrent-features"><a href="#react-18-and-concurrent-features" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React 18 and concurrent features </h2>
<p>In the keynote, we shared our vision for the future of React starting with React 18.</p>
<p>React 18 adds the long-awaited concurrent renderer and updates to Suspense without any major breaking changes. Apps can upgrade to React 18 and begin gradually adopting concurrent features with the amount of effort on par with any other major release.</p>
<p><strong>This means there is no concurrent mode, only concurrent features.</strong></p>
<p>In the keynote, we also shared our vision for Suspense, Server Components, new React working groups, and our long-term many-platform vision for React Native.</p>
<p>Watch the full keynote from <a href="https://twitter.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">Andrew Clark</a>, <a href="https://twitter.com/_jstejada" target="_blank" rel="nofollow noopener noreferrer">Juan Tejada</a>, <a href="https://twitter.com/potetotes" target="_blank" rel="nofollow noopener noreferrer">Lauren Tan</a>, and <a href="https://twitter.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">Rick Hanlon</a> here:</p>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe style="margin-top:10px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; " src="https://www.youtube.com/embed/FZ0cG47msEk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div>
<h2 id="react-18-for-application-developers"><a href="#react-18-for-application-developers" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React 18 for Application Developers </h2>
<p>In the keynote, we also announced that the React 18 RC is available to try now. Pending further feedback, this is the exact version of React that we will publish to stable early next year.</p>
<p>To try the React 18 RC, upgrade your dependencies:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">npm</span> <span class="token function">install</span> react@rc react-dom@rc</code></pre></div>
<p>and switch to the new <code class="gatsby-code-text">createRoot</code> API:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// before</span>
<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'root'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> container<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// after</span>
<span class="token keyword">const</span> container <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'root'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> root <span class="token operator">=</span> ReactDOM<span class="token punctuation">.</span><span class="token function">createRoot</span><span class="token punctuation">(</span>container<span class="token punctuation">)</span><span class="token punctuation">;</span>
root<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span><span class="token punctuation">/></span></span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>For a demo of upgrading to React 18, see <a href="https://twitter.com/shrutikapoor08" target="_blank" rel="nofollow noopener noreferrer">Shruti Kapoor</a>’s talk here:</p>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe style="margin-top:10px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; " src="https://www.youtube.com/embed/ytudH8je5ko" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div>
<h2 id="streaming-server-rendering-with-suspense"><a href="#streaming-server-rendering-with-suspense" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Streaming Server Rendering with Suspense </h2>
<p>React 18 also includes improvements to server-side rendering performance using Suspense.</p>
<p>Streaming server rendering lets you generate HTML from React components on the server, and stream that HTML to your users. In React 18, you can use <code class="gatsby-code-text">Suspense</code> to break down your app into smaller independent units which can be streamed independently of each other without blocking the rest of the app. This means users will see your content sooner and be able to start interacting with it much faster.</p>
<p>For a deep dive, see <a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</a>’s talk here:</p>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe style="margin-top:10px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; " src="https://www.youtube.com/embed/pj5N-Khihgc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div>
<h2 id="the-first-react-working-group"><a href="#the-first-react-working-group" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>The first React working group </h2>
<p>For React 18, we created our first Working Group to collaborate with a panel of experts, developers, library maintainers, and educators. Together we worked to create our gradual adoption strategy and refine new APIs such as <code class="gatsby-code-text">useId</code>, <code class="gatsby-code-text">useSyncExternalStore</code>, and <code class="gatsby-code-text">useInsertionEffect</code>.</p>
<p>For an overview of this work, see <a href="https://twitter.com/aakansha1216" target="_blank" rel="nofollow noopener noreferrer">Aakansha’ Doshi</a>’s talk:</p>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe style="margin-top:10px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; " src="https://www.youtube.com/embed/qn7gRClrC9U" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div>
<h2 id="react-developer-tooling"><a href="#react-developer-tooling" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Developer Tooling </h2>
<p>To support the new features in this release, we also announced the newly formed React DevTools team and a new Timeline Profiler to help developers debug their React apps.</p>
<p>For more information and a demo of new DevTools features, see <a href="https://twitter.com/brian_d_vaughn" target="_blank" rel="nofollow noopener noreferrer">Brian Vaughn</a>’s talk:</p>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe style="margin-top:10px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; " src="https://www.youtube.com/embed/oxDfrke8rZg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div>
<h2 id="react-without-memo"><a href="#react-without-memo" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React without memo </h2>
<p>Looking further into the future, <a href="https://twitter.com/Huxpro" target="_blank" rel="nofollow noopener noreferrer">Xuan Huang (黄玄)</a> shared an update from our React Labs research into an auto-memoizing compiler. Check out this talk for more information and a demo of the compiler prototype:</p>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe style="margin-top:10px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; " src="https://www.youtube.com/embed/lGEMwh32soc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div>
<h2 id="react-docs-keynote"><a href="#react-docs-keynote" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React docs keynote </h2>
<p><a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a> kicked off a section of talks about learning and designing with React with a keynote about our investment in React’s <a href="https://react.dev/" target="_blank" rel="nofollow noopener noreferrer">new docs</a>:</p>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe style="margin-top:10px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; " src="https://www.youtube.com/embed/mneDaMYOKP8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> </div>
<h1 id="and-more"><a href="#and-more" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>And more… </h1>
<p><strong>We also heard talks on learning and designing with React:</strong></p>
<ul>
<li>Debbie O’Brien: <a href="https://youtu.be/-7odLW_hG7s" target="_blank" rel="nofollow noopener noreferrer">Things I learnt from the new React docs</a>.</li>
<li>Sarah Rainsberger: <a href="https://youtu.be/5X-WEQflCL0" target="_blank" rel="nofollow noopener noreferrer">Learning in the Browser</a>.</li>
<li>Linton Ye: <a href="https://youtu.be/7cPWmID5XAk" target="_blank" rel="nofollow noopener noreferrer">The ROI of Designing with React</a>.</li>
<li>Delba de Oliveira: <a href="https://youtu.be/zL8cz2W0z34" target="_blank" rel="nofollow noopener noreferrer">Interactive playgrounds with React</a>.</li>
</ul>
<p><strong>Talks from the Relay, React Native, and PyTorch teams:</strong></p>
<ul>
<li>Robert Balicki: <a href="https://youtu.be/lhVGdErZuN4" target="_blank" rel="nofollow noopener noreferrer">Re-introducing Relay</a>.</li>
<li>Eric Rozell and Steven Moyes: <a href="https://youtu.be/9L4FFrvwJwY" target="_blank" rel="nofollow noopener noreferrer">React Native Desktop</a>.</li>
<li>Roman Rädle: <a href="https://youtu.be/NLj73vrc2I8" target="_blank" rel="nofollow noopener noreferrer">On-device Machine Learning for React Native</a></li>
</ul>
<p><strong>And talks from the community on accessibility, tooling, and Server Components:</strong></p>
<ul>
<li>Daishi Kato: <a href="https://youtu.be/oPfSC5bQPR8" target="_blank" rel="nofollow noopener noreferrer">React 18 for External Store Libraries</a>.</li>
<li>Diego Haz: <a href="https://youtu.be/dcm8fjBfro8" target="_blank" rel="nofollow noopener noreferrer">Building Accessible Components in React 18</a>.</li>
<li>Tafu Nakazaki: <a href="https://youtu.be/S4a0QlsH0pU" target="_blank" rel="nofollow noopener noreferrer">Accessible Japanese Form Components with React</a>.</li>
<li>Lyle Troxell: <a href="https://youtu.be/b3l4WxipFsE" target="_blank" rel="nofollow noopener noreferrer">UI tools for artists</a>.</li>
<li>Helen Lin: <a href="https://youtu.be/HS6vIYkSNks" target="_blank" rel="nofollow noopener noreferrer">Hydrogen + React 18</a>.</li>
</ul>
<h1 id="thank-you"><a href="#thank-you" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Thank you </h1>
<p>This was our first year planning a conference ourselves, and we have a lot of people to thank.</p>
<p>First, thanks to all of our speakers <a href="https://twitter.com/aakansha1216" target="_blank" rel="nofollow noopener noreferrer">Aakansha Doshi</a>, <a href="https://twitter.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">Andrew Clark</a>, <a href="https://twitter.com/brian_d_vaughn" target="_blank" rel="nofollow noopener noreferrer">Brian Vaughn</a>, <a href="https://twitter.com/dai_shi" target="_blank" rel="nofollow noopener noreferrer">Daishi Kato</a>, <a href="https://twitter.com/debs_obrien" target="_blank" rel="nofollow noopener noreferrer">Debbie O’Brien</a>, <a href="https://twitter.com/delba_oliveira" target="_blank" rel="nofollow noopener noreferrer">Delba de Oliveira</a>, <a href="https://twitter.com/diegohaz" target="_blank" rel="nofollow noopener noreferrer">Diego Haz</a>, <a href="https://twitter.com/EricRozell" target="_blank" rel="nofollow noopener noreferrer">Eric Rozell</a>, <a href="https://twitter.com/wizardlyhel" target="_blank" rel="nofollow noopener noreferrer">Helen Lin</a>, <a href="https://twitter.com/_jstejada" target="_blank" rel="nofollow noopener noreferrer">Juan Tejada</a>, <a href="https://twitter.com/potetotes" target="_blank" rel="nofollow noopener noreferrer">Lauren Tan</a>, <a href="https://twitter.com/lintonye" target="_blank" rel="nofollow noopener noreferrer">Linton Ye</a>, <a href="https://twitter.com/lyle" target="_blank" rel="nofollow noopener noreferrer">Lyle Troxell</a>, <a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a>, <a href="https://twitter.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">Rick Hanlon</a>, <a href="https://twitter.com/StatisticsFTW" target="_blank" rel="nofollow noopener noreferrer">Robert Balicki</a>, <a href="https://twitter.com/raedle" target="_blank" rel="nofollow noopener noreferrer">Roman Rädle</a>, <a href="https://twitter.com/sarah11918" target="_blank" rel="nofollow noopener noreferrer">Sarah Rainsberger</a>, <a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</a>, <a href="https://twitter.com/shrutikapoor08" target="_blank" rel="nofollow noopener noreferrer">Shruti Kapoor</a>, <a href="https://twitter.com/moyessa" target="_blank" rel="nofollow noopener noreferrer">Steven Moyes</a>, <a href="https://twitter.com/hawaiiman0" target="_blank" rel="nofollow noopener noreferrer">Tafu Nakazaki</a>, and  <a href="https://twitter.com/Huxpro" target="_blank" rel="nofollow noopener noreferrer">Xuan Huang (黄玄)</a>.</p>
<p>Thanks to everyone who helped provide feedback on talks including <a href="https://twitter.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">Andrew Clark</a>, <a href="https://twitter.com/dan_abramov" target="_blank" rel="nofollow noopener noreferrer">Dan Abramov</a>, <a href="https://twitter.com/mcc_abe" target="_blank" rel="nofollow noopener noreferrer">Dave McCabe</a>, <a href="https://twitter.com/Eli_White" target="_blank" rel="nofollow noopener noreferrer">Eli White</a>, <a href="https://twitter.com/en_JS" target="_blank" rel="nofollow noopener noreferrer">Joe Savona</a>,  <a href="https://twitter.com/potetotes" target="_blank" rel="nofollow noopener noreferrer">Lauren Tan</a>, <a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a>, and <a href="https://twitter.com/yungsters" target="_blank" rel="nofollow noopener noreferrer">Tim Yung</a>.</p>
<p>Thanks to <a href="https://twitter.com/potetotes" target="_blank" rel="nofollow noopener noreferrer">Lauren Tan</a> for setting up the conference Discord and serving as our Discord admin.</p>
<p>Thanks to <a href="https://twitter.com/sethwebster" target="_blank" rel="nofollow noopener noreferrer">Seth Webster</a> for feedback on overall direction and making sure we were focused on diversity and inclusion.</p>
<p>Thanks to <a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a> for spearheading our moderation effort, and <a href="https://twitter.com/AishaBlake" target="_blank" rel="nofollow noopener noreferrer">Aisha Blake</a> for creating our moderation guide, leading our moderation team, training the translators and moderators, and helping to moderate both events.</p>
<p>Thanks to our moderators <a href="https://twitter.com/jtannady" target="_blank" rel="nofollow noopener noreferrer">Jesslyn Tannady</a>, <a href="https://twitter.com/missuze" target="_blank" rel="nofollow noopener noreferrer">Suzie Grange</a>, <a href="https://twitter.com/beccaliz" target="_blank" rel="nofollow noopener noreferrer">Becca Bailey</a>, <a href="https://twitter.com/lunaleaps" target="_blank" rel="nofollow noopener noreferrer">Luna Wei</a>, <a href="https://twitter.com/jsjoeio" target="_blank" rel="nofollow noopener noreferrer">Joe Previte</a>, <a href="https://twitter.com/Cortinico" target="_blank" rel="nofollow noopener noreferrer">Nicola Corti</a>, <a href="https://twitter.com/gweterings" target="_blank" rel="nofollow noopener noreferrer">Gijs Weterings</a>, <a href="https://twitter.com/claudiopro" target="_blank" rel="nofollow noopener noreferrer">Claudio Procida</a>, Julia Neumann, Mengdi Chen, Jean Zhang, Ricky Li, and <a href="https://twitter.com/Huxpro" target="_blank" rel="nofollow noopener noreferrer">Xuan Huang (黄玄)</a>.</p>
<p>Thanks to <a href="https://twitter.com/manjula_dube" target="_blank" rel="nofollow noopener noreferrer">Manjula Dube</a>, <a href="https://twitter.com/apheri0" target="_blank" rel="nofollow noopener noreferrer">Sahil Mhapsekar</a>, and Vihang Patel from <a href="https://www.reactindia.io/" target="_blank" rel="nofollow noopener noreferrer">React India</a>, and <a href="https://twitter.com/jasmine_xby" target="_blank" rel="nofollow noopener noreferrer">Jasmine Xie</a>, <a href="https://twitter.com/QCL15" target="_blank" rel="nofollow noopener noreferrer">QiChang Li</a>, and <a href="https://twitter.com/anneincoding" target="_blank" rel="nofollow noopener noreferrer">YanLun Li</a> from <a href="https://twitter.com/ReactChina" target="_blank" rel="nofollow noopener noreferrer">React China</a> for helping moderate our replay event and keep it engaging for the community.</p>
<p>Thanks to Vercel for publishing their <a href="https://vercel.com/virtual-event-starter-kit" target="_blank" rel="nofollow noopener noreferrer">Virtual Event Starter Kit</a>, which the conference website was built on, and to <a href="https://twitter.com/leeerob" target="_blank" rel="nofollow noopener noreferrer">Lee Robinson</a> and <a href="https://twitter.com/delba_oliveira" target="_blank" rel="nofollow noopener noreferrer">Delba de Oliveira</a> for sharing their experience running Next.js Conf.</p>
<p>Thanks to <a href="https://twitter.com/wifelette" target="_blank" rel="nofollow noopener noreferrer">Leah Silber</a> for sharing her experience running conferences, learnings from running <a href="https://rustconf.com/" target="_blank" rel="nofollow noopener noreferrer">RustConf</a>, and for her book <a href="https://leanpub.com/eventdriven/" target="_blank" rel="nofollow noopener noreferrer">Event Driven</a> and the advice it contains for running conferences.</p>
<p>Thanks to <a href="https://twitter.com/_phzn" target="_blank" rel="nofollow noopener noreferrer">Kevin Lewis</a> and <a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a> for sharing their experience running Women of React Conf.</p>
<p>Thanks to <a href="https://twitter.com/aakansha1216" target="_blank" rel="nofollow noopener noreferrer">Aakansha Doshi</a>, <a href="https://twitter.com/laurieontech" target="_blank" rel="nofollow noopener noreferrer">Laurie Barth</a>, <a href="https://twitter.com/chantastic" target="_blank" rel="nofollow noopener noreferrer">Michael Chan</a>, and <a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</a> for their advice and ideas throughout planning.</p>
<p>Thanks to <a href="https://twitter.com/lebo" target="_blank" rel="nofollow noopener noreferrer">Dan Lebowitz</a> for help designing and building the conference website and tickets.</p>
<p>Thanks to Laura Podolak Waddell, Desmond Osei-Acheampong, Mark Rossi, Josh Toberman and others on the Facebook Video Productions team for recording the videos for the Keynote and Meta employee talks.</p>
<p>Thanks to our partner HitPlay for helping to organize the conference, editing all the videos in the stream, translating all the talks, and moderating the Discord in multiple languages.</p>
<p>Finally, thanks to all of our participants for making this a great React Conf!</p>]]></description><link>https://fr.reactjs.org/blog/2021/12/17/react-conf-2021-recap.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2021/12/17/react-conf-2021-recap.html</guid><pubDate>Fri, 17 Dec 2021 00:00:00 GMT</pubDate></item><item><title><![CDATA[The Plan for React 18]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<blockquote>
<p>Update Nov. 15th, 2021</p>
<p>React 18 is now in beta. More information about the status of the release is <a href="https://github.com/reactwg/react-18/discussions/112" target="_blank" rel="nofollow noopener noreferrer">available in the React 18 Working Group post</a>.</p>
</blockquote>
<p>The React team is excited to share a few updates:</p>
<ol>
<li>We’ve started work on the React 18 release, which will be our next major version.</li>
<li>We’ve created a Working Group to prepare the community for gradual adoption of new features in React 18.</li>
<li>We’ve published a React 18 Alpha so that library authors can try it and provide feedback.</li>
</ol>
<p>These updates are primarily aimed at maintainers of third-party libraries. If you’re learning, teaching, or using React to build user-facing applications, you can safely ignore this post. But you are welcome to follow the discussions in the React 18 Working Group if you’re curious!</p>
<h2 id="whats-coming-in-react-18"><a href="#whats-coming-in-react-18" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>What’s coming in React 18 </h2>
<p>When it’s released, React 18 will include out-of-the-box improvements (like <a href="https://github.com/reactwg/react-18/discussions/21" target="_blank" rel="nofollow noopener noreferrer">automatic batching</a>), new APIs (like <a href="https://github.com/reactwg/react-18/discussions/41" target="_blank" rel="nofollow noopener noreferrer"><code class="gatsby-code-text">startTransition</code></a>), and a <a href="https://github.com/reactwg/react-18/discussions/37" target="_blank" rel="nofollow noopener noreferrer">new streaming server renderer</a> with built-in support for <code class="gatsby-code-text">React.lazy</code>.</p>
<p>These features are possible thanks to a new opt-in mechanism we’re adding in React 18. It’s called “concurrent rendering” and it lets React prepare multiple versions of the UI at the same time. This change is mostly behind-the-scenes, but it unlocks new possibilities to improve both real and perceived performance of your app.</p>
<p>If you’ve been following our research into the future of React (we don’t expect you to!), you might have heard of something called “concurrent mode” or that it might break your app. In response to this feedback from the community, we’ve redesigned the upgrade strategy for gradual adoption. Instead of an all-or-nothing “mode”, concurrent rendering will only be enabled for updates triggered by one of the new features. In practice, this means <strong>you will be able to adopt React 18 without rewrites and try the new features at your own pace.</strong></p>
<h2 id="a-gradual-adoption-strategy"><a href="#a-gradual-adoption-strategy" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>A gradual adoption strategy </h2>
<p>Since concurrency in React 18 is opt-in, there are no significant out-of-the-box breaking changes to component behavior. <strong>You can upgrade to React 18 with minimal or no changes to your application code, with a level of effort comparable to a typical major React release</strong>. Based on our experience converting several apps to React 18, we expect that many users will be able to upgrade within a single afternoon.</p>
<p>We successfully shipped concurrent features to tens of thousands of components at Facebook, and in our experience, we’ve found that most React components “just work” without additional changes. We’re committed to making sure this is a smooth upgrade for the entire community, so today we’re announcing the React 18 Working Group.</p>
<h2 id="working-with-the-community"><a href="#working-with-the-community" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Working with the community </h2>
<p>We’re trying something new for this release: We’ve invited a panel of experts, developers, library authors, and educators from across the React community to participate in our <a href="https://github.com/reactwg/react-18" target="_blank" rel="nofollow noopener noreferrer">React 18 Working Group</a> to provide feedback, ask questions, and collaborate on the release. We couldn’t invite everyone we wanted to this initial, small group, but if this experiment works out, we hope there will be more in the future!</p>
<p><strong>The goal of the React 18 Working Group is to prepare the ecosystem for a smooth, gradual adoption of React 18 by existing applications and libraries.</strong> The Working Group is hosted on <a href="https://github.com/reactwg/react-18/discussions" target="_blank" rel="nofollow noopener noreferrer">GitHub Discussions</a> and is available for the public to read. Members of the working group can leave feedback, ask questions, and share ideas. The core team will also use the discussions repo to share our research findings. As the stable release gets closer, any important information will also be posted on this blog.</p>
<p>For more information on upgrading to React 18, or additional resources about the release, see the <a href="https://github.com/reactwg/react-18/discussions/4" target="_blank" rel="nofollow noopener noreferrer">React 18 announcement post</a>.</p>
<h2 id="accessing-the-react-18-working-group"><a href="#accessing-the-react-18-working-group" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Accessing the React 18 Working Group </h2>
<p>Everyone can read the discussions in the <a href="https://github.com/reactwg/react-18" target="_blank" rel="nofollow noopener noreferrer">React 18 Working Group repo</a>.</p>
<p>Because we expect an initial surge of interest in the Working Group, only invited members will be allowed to create or comment on threads. However, the threads are fully visible to the public, so everyone has access to the same information. We believe this is a good compromise between creating a productive environment for working group members, while maintaining transparency with the wider community.</p>
<p>As always, you can submit bug reports, questions, and general feedback to our <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">issue tracker</a>.</p>
<h2 id="how-to-try-react-18-alpha-today"><a href="#how-to-try-react-18-alpha-today" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>How to try React 18 Alpha today </h2>
<p>New alphas are <a href="https://github.com/reactwg/react-18/discussions/9" target="_blank" rel="nofollow noopener noreferrer">regularly published to npm using the <code class="gatsby-code-text">@alpha</code> tag</a>. These releases are built using the most recent commit to our main repo. When a feature or bugfix is merged, it will appear in an alpha the following weekday.</p>
<p>There may be significant behavioral or API changes between alpha releases. Please remember that <strong>alpha releases are not recommended for user-facing, production applications</strong>.</p>
<h2 id="projected-react-18-release-timeline"><a href="#projected-react-18-release-timeline" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Projected React 18 release timeline </h2>
<p>We don’t have a specific release date scheduled, but we expect it will take several months of feedback and iteration before React 18 is ready for most production applications.</p>
<ul>
<li>Library Alpha: Available today</li>
<li>Public Beta: At least several months</li>
<li>Release Candidate (RC): At least several weeks after Beta</li>
<li>General Availability: At least several weeks after RC</li>
</ul>
<p>More details about our projected release timeline are <a href="https://github.com/reactwg/react-18/discussions/9" target="_blank" rel="nofollow noopener noreferrer">available in the Working Group</a>. We’ll post updates on this blog when we’re closer to a public release.</p>]]></description><link>https://fr.reactjs.org/blog/2021/06/08/the-plan-for-react-18.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2021/06/08/the-plan-for-react-18.html</guid><pubDate>Tue, 08 Jun 2021 00:00:00 GMT</pubDate></item><item><title><![CDATA[Introducing Zero-Bundle-Size React Server Components]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>2020 has been a long year. As it comes to an end we wanted to share a special Holiday Update on our research into zero-bundle-size <strong>React Server Components</strong>.</p>
<p>To introduce React Server Components, we have prepared a talk and a demo. If you want, you can check them out during the holidays, or later when work picks back up in the new year.</p>
<br>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe src="https://www.youtube.com/embed/TQQPAU21ZUw" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" style=" position: absolute; top: 0; left: 0; width: 100%; height: 100%; "></iframe> </div>
<p><strong>React Server Components are still in research and development.</strong> We are sharing this work in the spirit of transparency and to get initial feedback from the React community. There will be plenty of time for that, so <strong>don’t feel like you have to catch up right now!</strong></p>
<p>If you want to check them out, we recommend to go in the following order:</p>
<ol>
<li><strong>Watch the talk</strong> to learn about React Server Components and see the demo.</li>
<li><strong><a href="http://github.com/reactjs/server-components-demo" target="_blank" rel="nofollow noopener noreferrer">Clone the demo</a></strong> to play with React Server Components on your computer.</li>
<li><strong><a href="https://github.com/reactjs/rfcs/pull/188" target="_blank" rel="nofollow noopener noreferrer">Read the RFC (with FAQ at the end)</a></strong> for a deeper technical breakdown and to provide feedback.</li>
</ol>
<p>We are excited to hear from you on the RFC or in replies to the <a href="https://twitter.com/reactjs" target="_blank" rel="nofollow noopener noreferrer">@reactjs</a> Twitter handle. Happy holidays, stay safe, and see you next year!</p>]]></description><link>https://fr.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html</guid><pubDate>Mon, 21 Dec 2020 00:00:00 GMT</pubDate></item><item><title><![CDATA[React v17.0]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Today, we are releasing React 17! We’ve written at length about the role of the React 17 release and the changes it contains in <a href="/blog/2020/08/10/react-v17-rc.html">the React 17 RC blog post</a>. This post is a brief summary of it, so if you’ve already read the RC post, you can skip this one.</p>
<h2 id="no-new-features"><a href="#no-new-features" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>No New Features </h2>
<p>The React 17 release is unusual because it doesn’t add any new developer-facing features. Instead, this release is primarily focused on <strong>making it easier to upgrade React itself</strong>.</p>
<p>In particular, React 17 is a “stepping stone” release that makes it safer to embed a tree managed by one version of React inside a tree managed by a different version of React.</p>
<p>It also makes it easier to embed React into apps built with other technologies.</p>
<h2 id="gradual-upgrades"><a href="#gradual-upgrades" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Gradual Upgrades </h2>
<p><strong>React 17 enables gradual React upgrades.</strong> When you upgrade from React 15 to 16 (or, this time, from React 16 to 17), you would usually upgrade your whole app at once. This works well for many apps. But it can get increasingly challenging if the codebase was written more than a few years ago and isn’t actively maintained. And while it’s possible to use two versions of React on the page, until React 17 this has been fragile and caused problems with events.</p>
<p>We’re fixing many of those problems with React 17. This means that <strong>when React 18 and the next future versions come out, you will now have more options</strong>. The first option will be to upgrade your whole app at once, like you might have done before. But you will also have an option to upgrade your app piece by piece. For example, you might decide to migrate most of your app to React 18, but keep some lazy-loaded dialog or a subroute on React 17.</p>
<p>This doesn’t mean you <em>have to</em> do gradual upgrades. <strong>For most apps, upgrading all at once is still the best solution.</strong> Loading two versions of React — even if one of them is loaded lazily on demand — is still not ideal. However, for larger apps that aren’t actively maintained, this option makes sense to consider, and React 17 lets those apps not get left behind.</p>
<p>We’ve prepared an <a href="https://github.com/reactjs/react-gradual-upgrade-demo/" target="_blank" rel="nofollow noopener noreferrer">example repository</a> demonstrating how to lazy-load an older version of React if necessary. This demo uses Create React App, but it should be possible to follow a similar approach with any other tool. We welcome demos using other tooling as pull requests.</p>
<blockquote>
<p>Note</p>
<p>We’ve <strong>postponed other changes</strong> until after React 17. The goal of this release is to enable gradual upgrades. If upgrading to React 17 were too difficult, it would defeat its purpose.</p>
</blockquote>
<h2 id="changes-to-event-delegation"><a href="#changes-to-event-delegation" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changes to Event Delegation </h2>
<p>To enable gradual updates, we’ve needed to make some changes to the React event system. React 17 is a major release because these changes are potentially breaking. You can check out our <a href="/docs/faq-versioning.html#breaking-changes">versioning FAQ</a> to learn more about our commitment to stability.</p>
<p>In React 17, React will no longer attach event handlers at the <code class="gatsby-code-text">document</code> level under the hood. Instead, it will attach them to the root DOM container into which your React tree is rendered:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">const</span> rootNode <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'root'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> rootNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>In React 16 and earlier, React would do <code class="gatsby-code-text">document.addEventListener()</code> for most events. React 17 will call <code class="gatsby-code-text">rootNode.addEventListener()</code> under the hood instead.</p>
<p>
  <a
    class="gatsby-resp-image-link"
    href="/static/bb4b10114882a50090b8ff61b3c4d0fd/31868/react_17_delegation.png"
    style="display: block"
    target="_blank"
    rel="noopener"
  >
  
  <span
    class="gatsby-resp-image-wrapper"
    style="position: relative; display: block;  max-width: 840px; margin-left: auto; margin-right: auto;"
  >
    <span
      class="gatsby-resp-image-background-image"
      style="padding-bottom: 77.14285714285715%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAACZklEQVQ4y12TW2/TQBCF8/+fygviFYHEL+AZCQkhFUGLQpP0kqRNE6exHV/X613v5UO2EyftSKOxd46PZ2fOjN491LR+8VDzfqH48qz5+KS654tD7tyPZ59Xmk8rxYfla9xIWs/Ra8fg0jhkG8/yJ5ynPuDf5kYczHtPYyzOGqyqUMvv+CriZH6IHc57rDFn572NWqLWGusopCJOMvarG+T8Gzp5pMk3eO9oYS3WOo/QhiTLiaK4+7Yl9wcfCNtYFgVhtCfaLEBscUZhigAr4gHTmqwqwt2OIAh6QueG3EBorUUpTV0JtklJXkR4VeC06Ai9bQZSrRvKUhDvYzLTV3jMdT20ziFUgzCOsixZZ5JdFoMue0KZ4I3quiVbMm0o64bJKmYhPLeBIBXN6wpr43guNVfLNf+eX4jjAFOGeGewVUuoO5xxjlAaZmHG118P/LyLyJXlKZJdfwfCnaj5vdox21fcppr7+ZgyD7uqrIiGWYrGMt5EXAUZ423Bj3lIkJfEwqCNY9SOzwLztGKaa2ZFwyIruF9OCKRBKomt80EWO9lws6+4Tiwz4bkMKia7jK2wqI4Qj3Lwd5swi1LuUsFdnDB/eeEuqUhFgbWmnyawzCSX64xJ2jDODH+2gllUsCoaKm36K7cVTrd7HnPJk3Qs47bZlk3taDyvJBMIxU0QEWi4Dmtuc8NKOoR5IxvZGJ5TwTzJeSxqNrWnNK7bhKNo+6F4wqJiuq+ZJpp1bYm1G6Qz6sH9SrU/yYzvXLnT+Un8x3corSdtPJX1PdlxUzrAcCX/ZjfPyc6iP+HafVZKobTGGMN/fgyCgH8QG5QAAAAASUVORK5CYII='); background-size: cover; display: block;"
    >
      <img
        class="gatsby-resp-image-image"
        style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;"
        alt="A diagram showing how React 17 attaches events to the roots rather than to the document"
        title=""
        src="/static/bb4b10114882a50090b8ff61b3c4d0fd/1e088/react_17_delegation.png"
        srcset="/static/bb4b10114882a50090b8ff61b3c4d0fd/65ed1/react_17_delegation.png 210w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/d10fb/react_17_delegation.png 420w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/1e088/react_17_delegation.png 840w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/78612/react_17_delegation.png 1260w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/21cdd/react_17_delegation.png 1680w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/31868/react_17_delegation.png 3496w"
        sizes="(max-width: 840px) 100vw, 840px"
      />
    </span>
  </span>
  
  </a>
    </p>
<p>We’ve confirmed that <a href="https://github.com/facebook/react/issues/7094" target="_blank" rel="nofollow noopener noreferrer">numerous</a> <a href="https://github.com/facebook/react/issues/8693" target="_blank" rel="nofollow noopener noreferrer">problems</a> <a href="https://github.com/facebook/react/issues/12518" target="_blank" rel="nofollow noopener noreferrer">reported</a> <a href="https://github.com/facebook/react/issues/13451" target="_blank" rel="nofollow noopener noreferrer">over</a> <a href="https://github.com/facebook/react/issues/4335" target="_blank" rel="nofollow noopener noreferrer">the</a> <a href="https://github.com/facebook/react/issues/1691" target="_blank" rel="nofollow noopener noreferrer">years</a> <a href="https://github.com/facebook/react/issues/285#issuecomment-253502585" target="_blank" rel="nofollow noopener noreferrer">on</a> <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">our</a> <a href="https://github.com/facebook/react/issues/11530" target="_blank" rel="nofollow noopener noreferrer">issue</a> <a href="https://github.com/facebook/react/issues/7128" target="_blank" rel="nofollow noopener noreferrer">tracker</a> related to integrating React with non-React code have been fixed by the new behavior.</p>
<p>If you run into issues with this change, <a href="/blog/2020/08/10/react-v17-rc.html#fixing-potential-issues">here’s a common way to resolve them</a>.</p>
<h2 id="other-breaking-changes"><a href="#other-breaking-changes" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Other Breaking Changes </h2>
<p><a href="/blog/2020/08/10/react-v17-rc.html#other-breaking-changes">The React 17 RC blog post</a> describes the rest of the breaking changes in React 17.</p>
<p>We’ve only had to change fewer than twenty components out of 100,000+ in the Facebook product code to work with these changes, so <strong>we expect that most apps can upgrade to React 17 without too much trouble</strong>. Please <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">tell us</a> if you run into problems.</p>
<h2 id="new-jsx-transform"><a href="#new-jsx-transform" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>New JSX Transform </h2>
<p>React 17 supports the <a href="/blog/2020/09/22/introducing-the-new-jsx-transform.html">new JSX transform</a>. We’ve also backported support for it to React 16.14.0, React 15.7.0, and 0.14.10. Note that it is completely opt-in, and you don’t have to use it. The classic JSX transform will keep working, and there are no plans to stop supporting it.</p>
<h2 id="react-native"><a href="#react-native" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Native </h2>
<p>React Native has a separate release schedule. We landed the support for React 17 in React Native 0.64. As always, you can track the release discussions on the React Native Community releases <a href="https://github.com/react-native-community/releases" target="_blank" rel="nofollow noopener noreferrer">issue tracker</a>.</p>
<h2 id="installation"><a href="#installation" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Installation </h2>
<p>To install React 17 with npm, run:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">npm</span> <span class="token function">install</span> react@17.0.0 react-dom@17.0.0</code></pre></div>
<p>To install React 17 with Yarn, run:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">yarn</span> <span class="token function">add</span> react@17.0.0 react-dom@17.0.0</code></pre></div>
<p>We also provide UMD builds of React via a CDN:</p>
<div class="gatsby-highlight" data-language="html"><pre class="gatsby-code-html"><code class="gatsby-code-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">crossorigin</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>https://unpkg.com/react@17.0.0/umd/react.production.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">crossorigin</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>https://unpkg.com/react-dom@17.0.0/umd/react-dom.production.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre></div>
<p>Refer to the documentation for <a href="/docs/installation.html">detailed installation instructions</a>.</p>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li>Add <code class="gatsby-code-text">react/jsx-runtime</code> and <code class="gatsby-code-text">react/jsx-dev-runtime</code> for the <a href="https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154-https-githubcom-babel-babel-pull-11154" target="_blank" rel="nofollow noopener noreferrer">new JSX transform</a>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> in <a href="https://github.com/facebook/react/pull/18299" target="_blank" rel="nofollow noopener noreferrer">#18299</a>)</li>
<li>Build component stacks from native error frames. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">#18561</a>)</li>
<li>Allow to specify <code class="gatsby-code-text">displayName</code> on context for improved stacks. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18224" target="_blank" rel="nofollow noopener noreferrer">#18224</a>)</li>
<li>Prevent <code class="gatsby-code-text">'use strict'</code> from leaking in the UMD bundles. (<a href="https://github.com/koba04" target="_blank" rel="nofollow noopener noreferrer">@koba04</a> in <a href="https://github.com/facebook/react/pull/19614" target="_blank" rel="nofollow noopener noreferrer">#19614</a>)</li>
<li>Stop using <code class="gatsby-code-text">fb.me</code> for redirects. (<a href="https://github.com/cylim" target="_blank" rel="nofollow noopener noreferrer">@cylim</a> in <a href="https://github.com/facebook/react/pull/19598" target="_blank" rel="nofollow noopener noreferrer">#19598</a>)</li>
</ul>
<h3 id="react-dom"><a href="#react-dom" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM </h3>
<ul>
<li>Delegate events to roots instead of <code class="gatsby-code-text">document</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18195" target="_blank" rel="nofollow noopener noreferrer">#18195</a> and <a href="https://github.com/facebook/react/pulls?q=is%3Apr+author%3Atrueadm+modern+event+is%3Amerged" target="_blank" rel="nofollow noopener noreferrer">others</a>)</li>
<li>Clean up all effects before running any next effects. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17947" target="_blank" rel="nofollow noopener noreferrer">#17947</a>)</li>
<li>Run <code class="gatsby-code-text">useEffect</code> cleanup functions asynchronously. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17925" target="_blank" rel="nofollow noopener noreferrer">#17925</a>)</li>
<li>Use browser <code class="gatsby-code-text">focusin</code> and <code class="gatsby-code-text">focusout</code> for <code class="gatsby-code-text">onFocus</code> and <code class="gatsby-code-text">onBlur</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/19186" target="_blank" rel="nofollow noopener noreferrer">#19186</a>)</li>
<li>Make all <code class="gatsby-code-text">Capture</code> events use the browser capture phase. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/19221" target="_blank" rel="nofollow noopener noreferrer">#19221</a>)</li>
<li>Don’t emulate bubbling of the <code class="gatsby-code-text">onScroll</code> event. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19464" target="_blank" rel="nofollow noopener noreferrer">#19464</a>)</li>
<li>Throw if <code class="gatsby-code-text">forwardRef</code> or <code class="gatsby-code-text">memo</code> component returns <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Remove event pooling. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18969" target="_blank" rel="nofollow noopener noreferrer">#18969</a>)</li>
<li>Stop exposing internals that won’t be needed by React Native Web. (<a href="https://github.com/necolas" target="_blank" rel="nofollow noopener noreferrer">@necolas</a> in <a href="https://github.com/facebook/react/pull/18483" target="_blank" rel="nofollow noopener noreferrer">#18483</a>)</li>
<li>Attach all known event listeners when the root mounts. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19659" target="_blank" rel="nofollow noopener noreferrer">#19659</a>)</li>
<li>Disable <code class="gatsby-code-text">console</code> in the second render pass of DEV mode double render. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>Deprecate the undocumented and misleading <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code> API. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/13407" target="_blank" rel="nofollow noopener noreferrer">#13407</a>)</li>
<li>Rename private field names used in the internals. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/18377" target="_blank" rel="nofollow noopener noreferrer">#18377</a>)</li>
<li>Don’t call User Timing API in development. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/18417" target="_blank" rel="nofollow noopener noreferrer">#18417</a>)</li>
<li>Disable console during the repeated render in Strict Mode. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>In Strict Mode, double-render components without Hooks too. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18430" target="_blank" rel="nofollow noopener noreferrer">#18430</a>)</li>
<li>Allow calling <code class="gatsby-code-text">ReactDOM.flushSync</code> during lifecycle methods (but warn). (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18759" target="_blank" rel="nofollow noopener noreferrer">#18759</a>)</li>
<li>Add the <code class="gatsby-code-text">code</code> property to the keyboard event objects. (<a href="https://github.com/bl00mber" target="_blank" rel="nofollow noopener noreferrer">@bl00mber</a> in <a href="https://github.com/facebook/react/pull/18287" target="_blank" rel="nofollow noopener noreferrer">#18287</a>)</li>
<li>Add the <code class="gatsby-code-text">disableRemotePlayback</code> property for <code class="gatsby-code-text">video</code> elements. (<a href="https://github.com/tombrowndev" target="_blank" rel="nofollow noopener noreferrer">@tombrowndev</a> in <a href="https://github.com/facebook/react/pull/18619" target="_blank" rel="nofollow noopener noreferrer">#18619</a>)</li>
<li>Add the <code class="gatsby-code-text">enterKeyHint</code> property for <code class="gatsby-code-text">input</code> elements. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18634" target="_blank" rel="nofollow noopener noreferrer">#18634</a>)</li>
<li>Warn when no <code class="gatsby-code-text">value</code> is provided to <code class="gatsby-code-text">&lt;Context.Provider></code>. (<a href="https://github.com/charlie1404" target="_blank" rel="nofollow noopener noreferrer">@charlie1404</a> in <a href="https://github.com/facebook/react/pull/19054" target="_blank" rel="nofollow noopener noreferrer">#19054</a>)</li>
<li>Warn when <code class="gatsby-code-text">memo</code> or <code class="gatsby-code-text">forwardRef</code> components return <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Improve the error message for invalid updates. (<a href="https://github.com/JoviDeCroock" target="_blank" rel="nofollow noopener noreferrer">@JoviDeCroock</a> in <a href="https://github.com/facebook/react/pull/18316" target="_blank" rel="nofollow noopener noreferrer">#18316</a>)</li>
<li>Exclude forwardRef and memo from stack frames. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18559" target="_blank" rel="nofollow noopener noreferrer">#18559</a>)</li>
<li>Improve the error message when switching between controlled and uncontrolled inputs. (<a href="https://github.com/vcarl" target="_blank" rel="nofollow noopener noreferrer">@vcarl</a> in <a href="https://github.com/facebook/react/pull/17070" target="_blank" rel="nofollow noopener noreferrer">#17070</a>)</li>
<li>Keep <code class="gatsby-code-text">onTouchStart</code>, <code class="gatsby-code-text">onTouchMove</code>, and <code class="gatsby-code-text">onWheel</code> passive. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19654" target="_blank" rel="nofollow noopener noreferrer">#19654</a>)</li>
<li>Fix <code class="gatsby-code-text">setState</code> hanging in development inside a closed iframe. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19220" target="_blank" rel="nofollow noopener noreferrer">#19220</a>)</li>
<li>Fix rendering bailout for lazy components with <code class="gatsby-code-text">defaultProps</code>. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> in <a href="https://github.com/facebook/react/pull/18539" target="_blank" rel="nofollow noopener noreferrer">#18539</a>)</li>
<li>Fix a false positive warning when <code class="gatsby-code-text">dangerouslySetInnerHTML</code> is <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18676" target="_blank" rel="nofollow noopener noreferrer">#18676</a>)</li>
<li>Fix Test Utils with non-standard <code class="gatsby-code-text">require</code> implementation. (<a href="https://github.com/just-boris" target="_blank" rel="nofollow noopener noreferrer">@just-boris</a> in <a href="https://github.com/facebook/react/pull/18632" target="_blank" rel="nofollow noopener noreferrer">#18632</a>)</li>
<li>Fix <code class="gatsby-code-text">onBeforeInput</code> reporting an incorrect <code class="gatsby-code-text">event.type</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/19561" target="_blank" rel="nofollow noopener noreferrer">#19561</a>)</li>
<li>Fix <code class="gatsby-code-text">event.relatedTarget</code> reported as <code class="gatsby-code-text">undefined</code> in Firefox. (<a href="https://github.com/claytercek" target="_blank" rel="nofollow noopener noreferrer">@claytercek</a> in <a href="https://github.com/facebook/react/pull/19607" target="_blank" rel="nofollow noopener noreferrer">#19607</a>)</li>
<li>Fix “unspecified error” in IE11. (<a href="https://github.com/hemakshis" target="_blank" rel="nofollow noopener noreferrer">@hemakshis</a> in <a href="https://github.com/facebook/react/pull/19664" target="_blank" rel="nofollow noopener noreferrer">#19664</a>)</li>
<li>Fix rendering into a shadow root. (<a href="https://github.com/Jack-Works" target="_blank" rel="nofollow noopener noreferrer">@Jack-Works</a> in <a href="https://github.com/facebook/react/pull/15894" target="_blank" rel="nofollow noopener noreferrer">#15894</a>)</li>
<li>Fix <code class="gatsby-code-text">movementX/Y</code> polyfill with capture events. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19672" target="_blank" rel="nofollow noopener noreferrer">#19672</a>)</li>
<li>Use delegation for <code class="gatsby-code-text">onSubmit</code> and <code class="gatsby-code-text">onReset</code> events. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19333" target="_blank" rel="nofollow noopener noreferrer">#19333</a>)</li>
<li>Improve memory usage. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18970" target="_blank" rel="nofollow noopener noreferrer">#18970</a>)</li>
</ul>
<h3 id="react-dom-server"><a href="#react-dom-server" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Server </h3>
<ul>
<li>Make <code class="gatsby-code-text">useCallback</code> behavior consistent with <code class="gatsby-code-text">useMemo</code> for the server renderer. (<a href="https://github.com/alexmckenley" target="_blank" rel="nofollow noopener noreferrer">@alexmckenley</a> in <a href="https://github.com/facebook/react/pull/18783" target="_blank" rel="nofollow noopener noreferrer">#18783</a>)</li>
<li>Fix state leaking when a function component throws. (<a href="https://github.com/pmaccart" target="_blank" rel="nofollow noopener noreferrer">@pmaccart</a> in <a href="https://github.com/facebook/react/pull/19212" target="_blank" rel="nofollow noopener noreferrer">#19212</a>)</li>
</ul>
<h3 id="react-test-renderer"><a href="#react-test-renderer" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Test Renderer </h3>
<ul>
<li>Improve <code class="gatsby-code-text">findByType</code> error message. (<a href="https://github.com/henryqdineen" target="_blank" rel="nofollow noopener noreferrer">@henryqdineen</a> in <a href="https://github.com/facebook/react/pull/17439" target="_blank" rel="nofollow noopener noreferrer">#17439</a>)</li>
</ul>
<h3 id="concurrent-mode-experimental"><a href="#concurrent-mode-experimental" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Concurrent Mode (Experimental) </h3>
<ul>
<li>Revamp the priority batching heuristics. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18796" target="_blank" rel="nofollow noopener noreferrer">#18796</a>)</li>
<li>Add the <code class="gatsby-code-text">unstable_</code> prefix before the experimental APIs. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remove <code class="gatsby-code-text">unstable_discreteUpdates</code> and <code class="gatsby-code-text">unstable_flushDiscreteUpdates</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remove the <code class="gatsby-code-text">timeoutMs</code> argument. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/19703" target="_blank" rel="nofollow noopener noreferrer">#19703</a>)</li>
<li>Disable <code class="gatsby-code-text">&lt;div hidden /></code> prerendering in favor of a different future API. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18917" target="_blank" rel="nofollow noopener noreferrer">#18917</a>)</li>
<li>Add <code class="gatsby-code-text">unstable_expectedLoadTime</code> to Suspense for CPU-bound trees. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/19936" target="_blank" rel="nofollow noopener noreferrer">#19936</a>)</li>
<li>Add an experimental <code class="gatsby-code-text">unstable_useOpaqueIdentifier</code> Hook. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> in <a href="https://github.com/facebook/react/pull/17322" target="_blank" rel="nofollow noopener noreferrer">#17322</a>)</li>
<li>Add an experimental <code class="gatsby-code-text">unstable_startTransition</code> API. (<a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a> in <a href="https://github.com/facebook/react/pull/19696" target="_blank" rel="nofollow noopener noreferrer">#19696</a>)</li>
<li>Using <code class="gatsby-code-text">act</code> in the test renderer no longer flushes Suspense fallbacks. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18596" target="_blank" rel="nofollow noopener noreferrer">#18596</a>)</li>
<li>Use global render timeout for CPU Suspense. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/19643" target="_blank" rel="nofollow noopener noreferrer">#19643</a>)</li>
<li>Clear the existing root content before mounting. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18730" target="_blank" rel="nofollow noopener noreferrer">#18730</a>)</li>
<li>Fix a bug with error boundaries. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18265" target="_blank" rel="nofollow noopener noreferrer">#18265</a>)</li>
<li>Fix a bug causing dropped updates in a suspended tree. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18384" target="_blank" rel="nofollow noopener noreferrer">#18384</a> and <a href="https://github.com/facebook/react/pull/18457" target="_blank" rel="nofollow noopener noreferrer">#18457</a>)</li>
<li>Fix a bug causing dropped render phase updates. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18537" target="_blank" rel="nofollow noopener noreferrer">#18537</a>)</li>
<li>Fix a bug in SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18412" target="_blank" rel="nofollow noopener noreferrer">#18412</a>)</li>
<li>Fix a bug causing Suspense fallback to show too early. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18411" target="_blank" rel="nofollow noopener noreferrer">#18411</a>)</li>
<li>Fix a bug with class components inside SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18448" target="_blank" rel="nofollow noopener noreferrer">#18448</a>)</li>
<li>Fix a bug with inputs that may cause updates to be dropped. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> in <a href="https://github.com/facebook/react/pull/18515" target="_blank" rel="nofollow noopener noreferrer">#18515</a> and <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18535" target="_blank" rel="nofollow noopener noreferrer">#18535</a>)</li>
<li>Fix a bug causing Suspense fallback to get stuck.  (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18663" target="_blank" rel="nofollow noopener noreferrer">#18663</a>)</li>
<li>Don’t cut off the tail of a SuspenseList if hydrating. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18854" target="_blank" rel="nofollow noopener noreferrer">#18854</a>)</li>
<li>Fix a bug in <code class="gatsby-code-text">useMutableSource</code> that may happen when <code class="gatsby-code-text">getSnapshot</code> changes. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18297" target="_blank" rel="nofollow noopener noreferrer">#18297</a>)</li>
<li>Fix a tearing bug in <code class="gatsby-code-text">useMutableSource</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18912" target="_blank" rel="nofollow noopener noreferrer">#18912</a>)</li>
<li>Warn if calling setState outside of render but before commit. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18838" target="_blank" rel="nofollow noopener noreferrer">#18838</a>)</li>
</ul>]]></description><link>https://fr.reactjs.org/blog/2020/10/20/react-v17.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2020/10/20/react-v17.html</guid><pubDate>Tue, 20 Oct 2020 00:00:00 GMT</pubDate></item><item><title><![CDATA[Introducing the New JSX Transform]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Although React 17 <a href="/blog/2020/08/10/react-v17-rc.html">doesn’t contain new features</a>, it will provide support for a new version of the JSX transform. In this post, we will describe what it is and how to try it.</p>
<h2 id="whats-a-jsx-transform"><a href="#whats-a-jsx-transform" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>What’s a JSX Transform? </h2>
<p>Browsers don’t understand JSX out of the box, so most React users rely on a compiler like Babel or TypeScript to <strong>transform JSX code into regular JavaScript</strong>. Many preconfigured toolkits like Create React App or Next.js also include a JSX transform under the hood.</p>
<p>Together with the React 17 release, we’ve wanted to make a few improvements to the JSX transform, but we didn’t want to break existing setups. This is why we <a href="https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154httpsgithubcombabelbabelpull11154" target="_blank" rel="nofollow noopener noreferrer">worked with Babel</a> to <strong>offer a new, rewritten version of the JSX transform</strong> for people who would like to upgrade.</p>
<p>Upgrading to the new transform is completely optional, but it has a few benefits:</p>
<ul>
<li>With the new transform, you can <strong>use JSX without importing React</strong>.</li>
<li>Depending on your setup, its compiled output may <strong>slightly improve the bundle size</strong>.</li>
<li>It will enable future improvements that <strong>reduce the number of concepts</strong> you need to learn React.</li>
</ul>
<p><strong>This upgrade will not change the JSX syntax and is not required.</strong> The old JSX transform will keep working as usual, and there are no plans to remove the support for it.</p>
<p><a href="/blog/2020/08/10/react-v17-rc.html">React 17 RC</a> already includes support for the new transform, so go give it a try! To make it easier to adopt, <strong>we’ve also backported its support</strong> to React 16.14.0, React 15.7.0, and React 0.14.10. You can find the upgrade instructions for different tools <a href="#how-to-upgrade-to-the-new-jsx-transform">below</a>.</p>
<p>Now let’s take a closer look at the differences between the old and the new transform.</p>
<h2 id="whats-different-in-the-new-transform"><a href="#whats-different-in-the-new-transform" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>What’s Different in the New Transform? </h2>
<p>When you use JSX, the compiler transforms it into React function calls that the browser can understand. <strong>The old JSX transform</strong> turned JSX into <code class="gatsby-code-text">React.createElement(...)</code> calls.</p>
<p>For example, let’s say your source code looks like this:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> React <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token plain-text">Hello World</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Under the hood, the old JSX transform turns it into regular JavaScript:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> React <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> React<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'h1'</span><span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">,</span> <span class="token string">'Hello world'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<blockquote>
<p>Note</p>
<p><strong>Your source code doesn’t need to change in any way.</strong> We’re describing how the JSX transform turns your JSX source code into the JavaScript code a browser can understand.</p>
</blockquote>
<p>However, this is not perfect:</p>
<ul>
<li>Because JSX was compiled into <code class="gatsby-code-text">React.createElement</code>, <code class="gatsby-code-text">React</code> needed to be in scope if you used JSX.</li>
<li>There are some <a href="https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#motivation" target="_blank" rel="nofollow noopener noreferrer">performance improvements and simplifications</a> that <code class="gatsby-code-text">React.createElement</code> does not allow.</li>
</ul>
<p>To solve these issues, React 17 introduces two new entry points to the React package that are intended to only be used by compilers like Babel and TypeScript. Instead of transforming JSX to <code class="gatsby-code-text">React.createElement</code>, <strong>the new JSX transform</strong> automatically imports special functions from those new entry points in the React package and calls them.</p>
<p>Let’s say that your source code looks like this:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token plain-text">Hello World</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>This is what the new JSX transform compiles it to:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Inserted by a compiler (don't import it yourself!)</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span>jsx <span class="token keyword">as</span> _jsx<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react/jsx-runtime'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token function">_jsx</span><span class="token punctuation">(</span><span class="token string">'h1'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">children</span><span class="token operator">:</span> <span class="token string">'Hello world'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Note how our original code <strong>did not need to import React</strong> to use JSX anymore! (But we would still need to import React in order to use Hooks or other exports that React provides.)</p>
<p><strong>This change is fully compatible with all of the existing JSX code</strong>, so you won’t have to change your components. If you’re curious, you can check out the <a href="https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#detailed-design" target="_blank" rel="nofollow noopener noreferrer">technical RFC</a> for more details about how the new transform works.</p>
<blockquote>
<p>Note</p>
<p>The functions inside <code class="gatsby-code-text">react/jsx-runtime</code> and <code class="gatsby-code-text">react/jsx-dev-runtime</code> must only be used by the compiler transform. If you need to manually create elements in your code, you should keep using <code class="gatsby-code-text">React.createElement</code>. It will continue to work and is not going away.</p>
</blockquote>
<h2 id="how-to-upgrade-to-the-new-jsx-transform"><a href="#how-to-upgrade-to-the-new-jsx-transform" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>How to Upgrade to the New JSX Transform </h2>
<p>If you aren’t ready to upgrade to the new JSX transform or if you are using JSX for another library, don’t worry. The old transform will not be removed and will continue to be supported.</p>
<p>If you want to upgrade, you will need two things:</p>
<ul>
<li><strong>A version of React that supports the new transform</strong> (<a href="/blog/2020/08/10/react-v17-rc.html">React 17 RC</a> and higher supports it, but we’ve also released React 16.14.0, React 15.7.0, and React 0.14.10 for people who are still on the older major versions).</li>
<li><strong>A compatible compiler</strong> (see instructions for different tools below).</li>
</ul>
<p>Since the new JSX transform doesn’t require React to be in scope, <a href="#removing-unused-react-imports">we’ve also prepared an automated script</a> that will remove the unnecessary imports from your codebase.</p>
<h3 id="create-react-app"><a href="#create-react-app" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Create React App </h3>
<p>Create React App <a href="https://github.com/facebook/create-react-app/releases/tag/v4.0.0" target="_blank" rel="nofollow noopener noreferrer">4.0.0</a>+ uses the new transform for compatible React versions.</p>
<h3 id="nextjs"><a href="#nextjs" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Next.js </h3>
<p>Next.js <a href="https://github.com/vercel/next.js/releases/tag/v9.5.3" target="_blank" rel="nofollow noopener noreferrer">v9.5.3</a>+ uses the new transform for compatible React versions.</p>
<h3 id="gatsby"><a href="#gatsby" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Gatsby </h3>
<p>Gatsby <a href="https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/CHANGELOG.md#22452-2020-08-28" target="_blank" rel="nofollow noopener noreferrer">v2.24.5</a>+ uses the new transform for compatible React versions.</p>
<blockquote>
<p>Note</p>
<p>If you get <a href="https://github.com/gatsbyjs/gatsby/issues/26979" target="_blank" rel="nofollow noopener noreferrer">this Gatsby error</a> after upgrading to React 17 RC, run <code class="gatsby-code-text">npm update</code> to fix it.</p>
</blockquote>
<h3 id="manual-babel-setup"><a href="#manual-babel-setup" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Manual Babel Setup </h3>
<p>Support for the new JSX transform is available in Babel <a href="https://babeljs.io/blog/2020/03/16/7.9.0" target="_blank" rel="nofollow noopener noreferrer">v7.9.0</a> and above.</p>
<p>First, you’ll need to update to the latest Babel and plugin transform.</p>
<p>If you are using <code class="gatsby-code-text">@babel/plugin-transform-react-jsx</code>:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for npm users</span>
<span class="token function">npm</span> update @babel/core @babel/plugin-transform-react-jsx</code></pre></div>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for yarn users</span>
<span class="token function">yarn</span> upgrade @babel/core @babel/plugin-transform-react-jsx</code></pre></div>
<p>If you are using <code class="gatsby-code-text">@babel/preset-react</code>:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for npm users</span>
<span class="token function">npm</span> update @babel/core @babel/preset-react</code></pre></div>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for yarn users</span>
<span class="token function">yarn</span> upgrade @babel/core @babel/preset-react</code></pre></div>
<p>Currently, the old transform <code class="gatsby-code-text">{"runtime": "classic"}</code> is the default option. To enable the new transform, you can pass <code class="gatsby-code-text">{"runtime": "automatic"}</code> as an option to <code class="gatsby-code-text">@babel/plugin-transform-react-jsx</code> or <code class="gatsby-code-text">@babel/preset-react</code>:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// If you are using @babel/preset-react</span>
<span class="token punctuation">{</span>
  <span class="token string-property property">"presets"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">[</span><span class="token string">"@babel/preset-react"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
      <span class="token string-property property">"runtime"</span><span class="token operator">:</span> <span class="token string">"automatic"</span>
    <span class="token punctuation">}</span><span class="token punctuation">]</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span></code></pre></div>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// If you're using @babel/plugin-transform-react-jsx</span>
<span class="token punctuation">{</span>
  <span class="token string-property property">"plugins"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">[</span><span class="token string">"@babel/plugin-transform-react-jsx"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
      <span class="token string-property property">"runtime"</span><span class="token operator">:</span> <span class="token string">"automatic"</span>
    <span class="token punctuation">}</span><span class="token punctuation">]</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Starting from Babel 8, <code class="gatsby-code-text">"automatic"</code> will be the default runtime for both plugins. For more information, check out the Babel documentation for <a href="https://babeljs.io/docs/en/babel-plugin-transform-react-jsx" target="_blank" rel="nofollow noopener noreferrer">@babel/plugin-transform-react-jsx</a> and <a href="https://babeljs.io/docs/en/babel-preset-react" target="_blank" rel="nofollow noopener noreferrer">@babel/preset-react</a>.</p>
<blockquote>
<p>Note</p>
<p>If you use JSX with a library other than React, you can use <a href="https://babeljs.io/docs/en/babel-preset-react#importsource" target="_blank" rel="nofollow noopener noreferrer">the <code class="gatsby-code-text">importSource</code> option</a> to import from that library instead — as long as it provides the necessary entry points. Alternatively, you can keep using the classic transform which will continue to be supported.</p>
<p>If you’re a library author and you are implementing the <code class="gatsby-code-text">/jsx-runtime</code> entry point for your library, keep in mind that <a href="https://github.com/facebook/react/issues/20031#issuecomment-710346866" target="_blank" rel="nofollow noopener noreferrer">there is a case</a> in which even the new transform has to fall back to <code class="gatsby-code-text">createElement</code> for backwards compatibility. In that case, it will auto-import <code class="gatsby-code-text">createElement</code> directly from the <em>root</em> entry point specified by <code class="gatsby-code-text">importSource</code>.</p>
</blockquote>
<h3 id="eslint"><a href="#eslint" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>ESLint </h3>
<p>If you are using <a href="https://github.com/yannickcr/eslint-plugin-react" target="_blank" rel="nofollow noopener noreferrer">eslint-plugin-react</a>, the <code class="gatsby-code-text">react/jsx-uses-react</code> and <code class="gatsby-code-text">react/react-in-jsx-scope</code> rules are no longer necessary and can be turned off or removed.</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token punctuation">{</span>
  <span class="token comment">// ...</span>
  <span class="token string-property property">"rules"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token comment">// ...</span>
    <span class="token string-property property">"react/jsx-uses-react"</span><span class="token operator">:</span> <span class="token string">"off"</span><span class="token punctuation">,</span>
    <span class="token string-property property">"react/react-in-jsx-scope"</span><span class="token operator">:</span> <span class="token string">"off"</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre></div>
<h3 id="typescript"><a href="#typescript" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>TypeScript </h3>
<p>TypeScript supports the new JSX transform in <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#jsx-factories" target="_blank" rel="nofollow noopener noreferrer">v4.1</a> and up.</p>
<h3 id="flow"><a href="#flow" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Flow </h3>
<p>Flow supports the new JSX transform in <a href="https://github.com/facebook/flow/releases/tag/v0.126.0" target="_blank" rel="nofollow noopener noreferrer">v0.126.0</a> and up, by adding <code class="gatsby-code-text">react.runtime=automatic</code> to your Flow configuration options. </p>
<h2 id="removing-unused-react-imports"><a href="#removing-unused-react-imports" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Removing Unused React Imports </h2>
<p>Because the new JSX transform will automatically import the necessary <code class="gatsby-code-text">react/jsx-runtime</code> functions, React will no longer need to be in scope when you use JSX. This might lead to unused React imports in your code. It doesn’t hurt to keep them, but if you’d like to remove them, we recommend running a <a href="https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb" target="_blank" rel="nofollow noopener noreferrer">“codemod”</a> script to remove them automatically:</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token builtin class-name">cd</span> your_project
npx react-codemod update-react-imports</code></pre></div>
<blockquote>
<p>Note</p>
<p>If you’re getting errors when running the codemod, try specifying a different JavaScript dialect when <code class="gatsby-code-text">npx react-codemod update-react-imports</code> asks you to choose one. In particular, at this moment the “JavaScript with Flow” setting supports newer syntax than the “JavaScript” setting even if you don’t use Flow. <a href="https://github.com/reactjs/react-codemod/issues" target="_blank" rel="nofollow noopener noreferrer">File an issue</a> if you run into problems.</p>
<p>Keep in mind that the codemod output will not always match your project’s coding style, so you might want to run <a href="https://prettier.io/" target="_blank" rel="nofollow noopener noreferrer">Prettier</a> after the codemod finishes for consistent formatting.</p>
</blockquote>
<p>Running this codemod will:</p>
<ul>
<li>Remove all unused React imports as a result of upgrading to the new JSX transform.</li>
<li>Change all default React imports (i.e. <code class="gatsby-code-text">import React from "react"</code>) to destructured named imports (ex. <code class="gatsby-code-text">import { useState } from "react"</code>) which is the preferred style going into the future. This codemod <strong>will not</strong> affect the existing namespace imports (i.e. <code class="gatsby-code-text">import * as React from "react"</code>) which is also a valid style. The default imports will keep working in React 17, but in the longer term we encourage moving away from them.</li>
</ul>
<p>For example,</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> React <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token plain-text">Hello World</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>will be replaced with</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token plain-text">Hello World</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>If you use some other import from React — for example, a Hook — then the codemod will convert it to a named import.</p>
<p>For example,</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> React <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> <span class="token punctuation">[</span>text<span class="token punctuation">,</span> setText<span class="token punctuation">]</span> <span class="token operator">=</span> React<span class="token punctuation">.</span><span class="token function">useState</span><span class="token punctuation">(</span><span class="token string">'Hello World'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>text<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>will be replaced with</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> <span class="token punctuation">{</span> useState <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> <span class="token punctuation">[</span>text<span class="token punctuation">,</span> setText<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token function">useState</span><span class="token punctuation">(</span><span class="token string">'Hello World'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>text<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>In addition to cleaning up unused imports, this will also help you prepare for a future major version of React (not React 17) which will support ES Modules and not have a default export.</p>
<h2 id="thanks"><a href="#thanks" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Thanks </h2>
<p>We’d like to thank Babel, TypeScript, Create React App, Next.js, Gatsby, ESLint, and Flow maintainers for their help implementing and integrating the new JSX transform. We also want to thank the React community for their feedback and discussion on the related <a href="https://github.com/reactjs/rfcs/pull/107" target="_blank" rel="nofollow noopener noreferrer">technical RFC</a>.</p>]]></description><link>https://fr.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html</guid><pubDate>Tue, 22 Sep 2020 00:00:00 GMT</pubDate></item><item><title><![CDATA[React v17.0 Release Candidate : pas de nouvelles fonctionnalités]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Nous publions aujourd’hui la première <em>Release Candidate</em> de React 17.  Déjà 2 ans et demi se sont écoulés depuis <a href="/blog/2017/09/26/react-v16.0.html">la précédente version majeure de React</a>, ce qui fait long, même pour nous !  Dans ce billet de blog, nous allons décrire le rôle de cette version majeure, les changements que vous pouvez en attendre, et la façon de l’essayer.</p>
<h2 id="no-new-features"><a href="#no-new-features" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Pas de nouvelles fonctionnalités </h2>
<p>La version 17 de React est inhabituelle en ce qu’elle n’ajoute pas de fonctionnalités à destination des développeur·se·s.  Elle se concentre plutôt sur <strong>la simplification des mises à jour de React-même.</strong></p>
<p>Nous travaillons activement sur les nouvelles fonctionnalités de React, mais elle ne figurent pas dans cette version.  La version 17 de React est au cœur de notre stratégie visant à sortir de nouvelles versions que tous nos utilisateurs pourront adopter facilement.</p>
<p>Pour être plus précis, <strong>React 17 est une version « passerelle »</strong> qui fiabilise l’intégration, au sein d’un arbre de composants géré par une version de React, d’un arbre géré par une version différente.</p>
<h2 id="gradual-upgrades"><a href="#gradual-upgrades" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Mises à jour graduelles </h2>
<p>Depuis 7 ans, les mises à jour de React ont toujours été « tout-ou-rien ».  Soit vous restiez sur une ancienne version, soit vous mettiez à jour toute votre application.  Il n’y avait pas de troisième voie.</p>
<p>Ça a fonctionné jusqu’ici, mais on commence à sentir les limites de cette stratégie de mise à jour « tout-ou-rien ».  Certaines évolutions de l’API, telles que la dépréciation de <a href="/docs/legacy-context.html">l’API historique des Contextes</a>, ne peuvent être réalisées de façon automatique.  Même si la plupart des applis écrites aujourd’hui ne s’en servent jamais, nous devons continuer à les prendre en charge dans React.  Il nous faut alors choisir entre continuer indéfiniment ou condamner certaines applis à rester sur une version ancienne de React : un dilemme désagréable.</p>
<p>Nous avons donc voulu proposer un autre chemin.</p>
<p><strong>React 17 permet des mises à jour graduelles de React.</strong> Lorsque vous avez migré de React 15 à 16 (et bientôt de React 16 à 17), vous avez normalement dû migrer toute votre appli d’un bloc.  Ça fonctionne bien pour de nombreuses applis.  Mais ça devient de plus en plus délicat  lorsque la base de code date de plusieurs années et n’est pas activement maintenue.  Même s’il reste possible d’utiliser deux versions de React sur une même page, jusqu’à React 17 c’était un exercice périlleux et pouvait poser des problèmes liés à la gestion des événements.</p>
<p>Nous réglons la majorité de ces soucis avec React 17. Ça signifie que <strong>lorsque React 18 et les versions ultérieures sortiront, vous aurez désormais davantage d’options</strong>. La première sera de mettre à jour votre appli entière d’un bloc, comme vous le faisiez jusqu’ici.  Mais vous pourrez aussi choisir de la mettre à jour par étapes.  Par exemple, vous pourriez décider de migrer l’essentiel vers React 18, mais de garder une boîte de dialogue ou une sous-route sur React 17.</p>
<p>Vous ne <strong>devez</strong> pas pour autant procéder de façon graduelle.  Dans la plupart des cas, une mise à jour intégrale restera la meilleure solution.  Charger deux versions de React—quand bien même l’une serait chargée paresseusement—n’est toujours pas idéal.  Ceci dit, pour de grosses applis qui ne sont pas activement maintenues, cette option pourrait être pertinente, et React 17 permet à de telles applis de ne pas être coincées avec de vieilles versions.</p>
<p>Afin de permettre ces mises à jour graduelles, nous avons dû modifier certaines choses dans le système de gestion des événements de React.  React 17 est une version majeure car certains de ces changements peuvent casser la compatibilité ascendante.  En pratique, nous n’avons eu qu’une vingtaine de composants à ajuster (sur plus de 100 000), aussi <strong>nous estimons que la large majorité des applis pourront migrer vers React 17 sans trop de difficultés</strong>. Si vous rencontrez des obstacles, <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">dites-le-nous</a>.</p>
<h3 id="demo-of-gradual-upgrades"><a href="#demo-of-gradual-upgrades" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Démo de mises à jour graduelles </h3>
<p>Nous avons préparé un <a href="https://github.com/reactjs/react-gradual-upgrade-demo/" target="_blank" rel="nofollow noopener noreferrer">dépôt d’exemple</a> illustrant la façon de charger paresseusement une ancienne version de React si nécessaire.  Cette démo utilise Create React App, mais vous pouvez suivre une approche similaire quel que soit l’outil.  Nous accepterons avec joie des démos basées sur d’autres outils que vous nous enverriez au travers de <em>pull requests</em>.</p>
<blockquote>
<p>Remarque</p>
<p>Nous avons <strong>différé les autres modifications</strong> pour après React 17.  L’objectif de cette version est de permettre les mises à jour graduelles.  Si adopter React 17 était trop lourd, ça nuirait à cette ambition.</p>
</blockquote>
<h2 id="changes-to-event-delegation"><a href="#changes-to-event-delegation" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Modifications de la délégation d’événements </h2>
<p>Techniquement, il a toujours été possible d’imbriquer des applis développées avec des versions différentes de React.  Toutefois, le résultat était plutôt fragile en raison du système d’événements de React.</p>
<p>Dans des composants React, vous définissez habituellement des gestionnaires d’événements en ligne sous forme de <em>props</em> :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>handleClick<span class="token punctuation">}</span></span><span class="token punctuation">></span></span></code></pre></div>
<p>L’équivalent du code ci-dessus en DOM natif ressemblerait à ceci :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx">myButton<span class="token punctuation">.</span><span class="token function">addEventListener</span><span class="token punctuation">(</span><span class="token string">'click'</span><span class="token punctuation">,</span> handleClick<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Cependant, pour la plupart des événements, React n’attache pas réellement les gestionnaires aux nœuds DOM sur lesquels vous les déclarez.  Au lieu de ça, React attache un gestionnaire par événement directement sur le nœud <code class="gatsby-code-text">document</code>.  Ça s’appelle de la <a href="https://davidwalsh.name/event-delegate" target="_blank" rel="nofollow noopener noreferrer">délégation d’événements</a>. Non seulement ça améliore la performance des gros arbres applicatifs, mais ça facilite en prime l’ajout de fonctionnalités telles que <a href="https://twitter.com/dan_abramov/status/1200118229697486849" target="_blank" rel="nofollow noopener noreferrer">rejouer les événements</a>.</p>
<p>React recourt automatiquement à la délégation d’événements depuis sa première version.  Quand un événement DOM est déclenché sur le document, React retrouve le composant à appeler, après quoi l’événement React « bouillonne » vers le haut de l’arbre, en passant au travers des composants parents.  Mais en coulisses, l’événement natif a déjà bouillonné jusqu’au niveau de <code class="gatsby-code-text">document</code>, où sont installés les gestionnaires d’événements de React.</p>
<p>Ça présente un souci pour les mises à jour graduelles.</p>
<p>Si vous avez de multiples versions de React sur la page, elles inscrivent toutes leurs gestionnaires d‘événements à la racine.  Ça enfreint la sémantique de <code class="gatsby-code-text">e.stopPropagation()</code> : si un arbre imbriqué a stoppé la propagation d’un événement, l’arbre conteneur le recevrait tout de même.  Il est donc périlleux d’imbriquer des versions distinctes de React.  Ce cas de figure n’a rien de théorique : l’éditeur Atom, par exemple, <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">a buté dessus</a> il y a déjà quatre ans.</p>
<p>Voilà pourquoi nous changeons la façon dont React, en coulisses, attache les événements aux nœuds du DOM.</p>
<p><strong>Dans React 17, React n’attachera plus les gestionnaires d’événements au niveau de <code class="gatsby-code-text">document</code>.  Au lieu de ça, il les attachera au conteneur DOM racine au sein duquel votre arbre React fait son rendu :</strong></p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">const</span> rootNode <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'root'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> rootNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Jusqu’à React 16 inclus, React aurait fait un <code class="gatsby-code-text">document.addEventListener()</code> pour la plupart des événements.  À compter de React 17, il appellera plutôt <code class="gatsby-code-text">rootNode.addEventListener()</code> sous le capot.</p>
<p>
  <a
    class="gatsby-resp-image-link"
    href="/static/bb4b10114882a50090b8ff61b3c4d0fd/31868/react_17_delegation.png"
    style="display: block"
    target="_blank"
    rel="noopener"
  >
  
  <span
    class="gatsby-resp-image-wrapper"
    style="position: relative; display: block;  max-width: 840px; margin-left: auto; margin-right: auto;"
  >
    <span
      class="gatsby-resp-image-background-image"
      style="padding-bottom: 77.14285714285715%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAACZklEQVQ4y12TW2/TQBCF8/+fygviFYHEL+AZCQkhFUGLQpP0kqRNE6exHV/X613v5UO2EyftSKOxd46PZ2fOjN491LR+8VDzfqH48qz5+KS654tD7tyPZ59Xmk8rxYfla9xIWs/Ra8fg0jhkG8/yJ5ynPuDf5kYczHtPYyzOGqyqUMvv+CriZH6IHc57rDFn572NWqLWGusopCJOMvarG+T8Gzp5pMk3eO9oYS3WOo/QhiTLiaK4+7Yl9wcfCNtYFgVhtCfaLEBscUZhigAr4gHTmqwqwt2OIAh6QueG3EBorUUpTV0JtklJXkR4VeC06Ai9bQZSrRvKUhDvYzLTV3jMdT20ziFUgzCOsixZZ5JdFoMue0KZ4I3quiVbMm0o64bJKmYhPLeBIBXN6wpr43guNVfLNf+eX4jjAFOGeGewVUuoO5xxjlAaZmHG118P/LyLyJXlKZJdfwfCnaj5vdox21fcppr7+ZgyD7uqrIiGWYrGMt5EXAUZ423Bj3lIkJfEwqCNY9SOzwLztGKaa2ZFwyIruF9OCKRBKomt80EWO9lws6+4Tiwz4bkMKia7jK2wqI4Qj3Lwd5swi1LuUsFdnDB/eeEuqUhFgbWmnyawzCSX64xJ2jDODH+2gllUsCoaKm36K7cVTrd7HnPJk3Qs47bZlk3taDyvJBMIxU0QEWi4Dmtuc8NKOoR5IxvZGJ5TwTzJeSxqNrWnNK7bhKNo+6F4wqJiuq+ZJpp1bYm1G6Qz6sH9SrU/yYzvXLnT+Un8x3corSdtPJX1PdlxUzrAcCX/ZjfPyc6iP+HafVZKobTGGMN/fgyCgH8QG5QAAAAASUVORK5CYII='); background-size: cover; display: block;"
    >
      <img
        class="gatsby-resp-image-image"
        style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;"
        alt="Un diagramme illustrant la façon dont React 17 attache les événements aux racines de rendu plutôt qu’au document"
        title=""
        src="/static/bb4b10114882a50090b8ff61b3c4d0fd/1e088/react_17_delegation.png"
        srcset="/static/bb4b10114882a50090b8ff61b3c4d0fd/65ed1/react_17_delegation.png 210w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/d10fb/react_17_delegation.png 420w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/1e088/react_17_delegation.png 840w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/78612/react_17_delegation.png 1260w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/21cdd/react_17_delegation.png 1680w,
/static/bb4b10114882a50090b8ff61b3c4d0fd/31868/react_17_delegation.png 3496w"
        sizes="(max-width: 840px) 100vw, 840px"
      />
    </span>
  </span>
  
  </a>
    </p>
<p>Grâce à ce changement, <strong>il est désormais plus fiable d’imbriquer un arbre React géré par une version donnée dans un arbre géré par une version différente de React</strong>.  Remarquez que pour que ça fonctionne, les deux versions doivent être 17 ou ultérieure, raison pour laquelle il est vital de mettre à jour vers React 17.  En un sens, React 17 est une version « passerelle » qui rend possible les mises à jour graduelles ultérieures.</p>
<p>Cette modification <strong>facilite aussi l’imbrication de React dans des applis construites avec d’autres technologies</strong>. Par exemple, si la « coquille » extérieure de votre appli était écrite avec jQuery, mais que le code plus récent à l’intérieur était écrit avec React, <code class="gatsby-code-text">e.stopPropagation()</code> au sein du code React l’empêcherait désormais d’atteindre le code jQuery—exactement comme vous êtes en droit de l’attendre.  Ça marche aussi dans l’autre sens.  Si vous n’aimez plus React et voulez réécrire votre appli (par exemple, avec jQuery) vous pouvez commencer à convertir le bloc externe vers jQuery sans casser la propagation des événements.</p>
<p>Nous avons pu vérifier que de <a href="https://github.com/facebook/react/issues/7094" target="_blank" rel="nofollow noopener noreferrer">nombreux</a> <a href="https://github.com/facebook/react/issues/8693" target="_blank" rel="nofollow noopener noreferrer">problèmes</a> <a href="https://github.com/facebook/react/issues/12518" target="_blank" rel="nofollow noopener noreferrer">signalés</a> <a href="https://github.com/facebook/react/issues/13451" target="_blank" rel="nofollow noopener noreferrer">au</a> <a href="https://github.com/facebook/react/issues/4335" target="_blank" rel="nofollow noopener noreferrer">fil</a> <a href="https://github.com/facebook/react/issues/1691" target="_blank" rel="nofollow noopener noreferrer">du</a> <a href="https://github.com/facebook/react/issues/285#issuecomment-253502585" target="_blank" rel="nofollow noopener noreferrer">temps</a> <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">sur notre</a> <a href="https://github.com/facebook/react/issues/11530" target="_blank" rel="nofollow noopener noreferrer">suivi</a> <a href="https://github.com/facebook/react/issues/7128" target="_blank" rel="nofollow noopener noreferrer">de bugs</a>, liés à l’intégration de React avec du code non React, ont bien été réglés avec ce nouveau comportement.</p>
<blockquote>
<p>Remarque</p>
<p>Vous vous demandez peut-être si ça casse les <a href="/docs/portals.html">portails</a> situés hors du conteneur racine applicatif.  Dans la mesure où React écoute <em>aussi</em> les événements des conteneurs de portails, ça ne pose aucun problème.</p>
</blockquote>
<h4 id="fixing-potential-issues"><a href="#fixing-potential-issues" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Corriger les problèmes éventuels </h4>
<p>Comme avec n’importe quelle rupture de la compatibilité ascendante, vous aurez sans doute besoin d’ajuster du code ici ou là.  Chez Facebook, nous avons dû ajuster environ 10 modules au total (sur plusieurs milliers) pour que tout remarche.</p>
<p>Par exemple, si vous ajoutez manuellement des écouteurs DOM avec <code class="gatsby-code-text">document.addEventListener(...)</code>, vous vous attendez peut-être à y retrouver tous les événements React.  Jusqu’à React 16 inclus, même si vous appeliez <code class="gatsby-code-text">e.stopPropagation()</code> dans un gestionnaire d’événement React, vos écouteurs manuels sur <code class="gatsby-code-text">document</code> les recevaient tout de même, puisque l’événement natif sous-jacent était <em>déjà</em> au niveau du document. À partir de React 17, la propagation <em>cesserait</em> (comme demandé !), du coup vos gestionnaires <code class="gatsby-code-text">document</code> ne seraient pas déclenchés :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx">document<span class="token punctuation">.</span><span class="token function">addEventListener</span><span class="token punctuation">(</span><span class="token string">'click'</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// Ce gestionnaire manuel ne recevra plus les clics issus</span>
  <span class="token comment">// de composants React qui appelleraient e.stopPropagation()</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Vous pouvez corriger ce type de code en convertissant votre écouteur pour utiliser la <a href="https://javascript.info/bubbling-and-capturing#capturing" target="_blank" rel="nofollow noopener noreferrer">phase de capture</a>. Pour cela, ajoutez <code class="gatsby-code-text">{ capture: true }</code> en troisième argument de <code class="gatsby-code-text">document.addEventListener</code> :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx">document<span class="token punctuation">.</span><span class="token function">addEventListener</span><span class="token punctuation">(</span><span class="token string">'click'</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// À présent ce gestionnaire d’événement utilise la phase</span>
  <span class="token comment">// de capture, il recevra donc *tous* les événements de clic</span>
  <span class="token comment">// en-dessous de son niveau !</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">capture</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Remarquez que cette approche est plus robuste de façon générale ; par exemple, elle corrigera sans doute des bugs existants dans votre code qui survenaient lorsque <code class="gatsby-code-text">e.stopPropagation()</code> était appelé hors d’un gestionnaire d’événement React.  En d’autres termes, <strong>la propagation des événements dans React 17 sera plus conforme à celle du DOM lui-même</strong>.</p>
<h2 id="other-breaking-changes"><a href="#other-breaking-changes" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Autres ruptures de compatibilité </h2>
<p>Nous avons limité au maximum les ruptures de compatibilité ascendante dans React 17.  Par exemple, nous n’y retirons pas les méthodes marquées comme dépréciées dans de précédentes versions.  Toutefois, il y reste quelques ruptures que, d’après notre expérience, nous avons jugées relativement bénignes.  Au total nous n’avons eu à ajuster, pour les prendre en compte, qu’une vingtaine de nos plus de 100 000 composants.</p>
<h3 id="aligning-with-browsers"><a href="#aligning-with-browsers" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>S’aligner sur les navigateurs </h3>
<p>Nous avons apporté quelques ajustements mineurs au système de gestion d’événements :</p>
<ul>
<li>L’événement <code class="gatsby-code-text">onScroll</code> <strong>ne bouillonne plus</strong> afin d’éviter un comportement <a href="https://github.com/facebook/react/issues/15723" target="_blank" rel="nofollow noopener noreferrer">fréquemment déroutant</a>.</li>
<li>Les événements React <code class="gatsby-code-text">onFocus</code> et <code class="gatsby-code-text">onBlur</code> utilisent désormais sous le capot les événements natifs <code class="gatsby-code-text">focusin</code> et <code class="gatsby-code-text">focusout</code>, qui correspondent davantage au comportement existant de React et fournissent parfois davantage d’informations.</li>
<li>Les événements en phase de capture (ex. <code class="gatsby-code-text">onClickCapture</code>) utilisent désormais des écouteurs natifs exploitant réellement la phase de capture.</li>
</ul>
<p>Ces changements alignent davantage React sur le comportement natif du navigateur et améliorent l’interopérabilité.</p>
<blockquote>
<p>Remarque</p>
<p>Même si React 17 est passé de <code class="gatsby-code-text">focus</code> à <code class="gatsby-code-text">focusin</code> <em>sous le capot</em> pour l’événement <code class="gatsby-code-text">onFocus</code>, remarquez que ça n’a <strong>pas</strong> affecté le comportement de bouillonnement.  Dans React, l’événement <code class="gatsby-code-text">onFocus</code> a toujours bouillonné et continuera à le faire dans React 17 car c’est un comportement par défaut généralement plus utile.  Voyez <a href="https://codesandbox.io/s/strange-albattani-7tqr7?file=/src/App.js" target="_blank" rel="nofollow noopener noreferrer">ce bac à sable</a> pour explorer les diverses vérifications que vous pouvez ajouter selon votre cas d’utilisation.</p>
</blockquote>
<h3 id="no-event-pooling"><a href="#no-event-pooling" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>La fin du recyclage d’événements </h3>
<p>React 17 met un terme à l’optimisation de « recyclage d’événements » employée jusqu’ici.  Celle-ci n’améliore en fait pas les performances sur les navigateurs modernes, mais peut s’avérer déroutante même pour les utilisateur·rice·s expérimenté·e·s de React :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">function</span> <span class="token function">handleChange</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">setData</span><span class="token punctuation">(</span><span class="token parameter">data</span> <span class="token operator">=></span> <span class="token punctuation">(</span><span class="token punctuation">{</span>
    <span class="token operator">...</span>data<span class="token punctuation">,</span>
    <span class="token comment">// Ça va planter jusqu’à React 16 inclus :</span>
    <span class="token literal-property property">text</span><span class="token operator">:</span> e<span class="token punctuation">.</span>target<span class="token punctuation">.</span>value
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Le souci vient ici du fait que React réutilisait les objets événements d’un événement à l’autre afin d’améliorer la performance sur les vieux navigateurs, et réinitialisait tous les champs de l’événement à <code class="gatsby-code-text">null</code> entre deux utilisations.  Jusqu’à React 16 inclus, il vous fallait appeler <code class="gatsby-code-text">e.persist()</code> pour pouvoir continuer à utiliser l’événement, par exemple y lire une propriété définie plus tôt.</p>
<p><strong>Dans React 17, ce code marchera comme attendu.  La vieille optimisation de recyclage d’événements a été entièrement retirée, de sorte que vous pouvez lire les champs des événements partout où vous le souhaitez.</strong></p>
<p>Le comportement change, ce qui fait qu’on le signale comme une rupture de compatibilité, mais en pratique ça n’a rien cassé chez Facebook. (Ça a peut-être même corrigé quelques bugs !)  Remarquez que <code class="gatsby-code-text">e.persist()</code> reste disponible sur l’objet d’événement React, mais elle ne fait plus rien.</p>
<h3 id="effect-cleanup-timing"><a href="#effect-cleanup-timing" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Planification du nettoyage d’effet </h3>
<p>Nous améliorons la cohérence de planification de la fonction de nettoyage de <code class="gatsby-code-text">useEffect</code>.</p>
<div class="gatsby-highlight has-highlighted-lines" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token function">useEffect</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token comment">// L’effet à proprement parler est ici.</span>
<span class="gatsby-highlight-code-line">  <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span></span><span class="gatsby-highlight-code-line">    <span class="token comment">// Et voici son nettoyage.</span></span><span class="gatsby-highlight-code-line">  <span class="token punctuation">}</span><span class="token punctuation">;</span></span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>La plupart des effets n’ont pas besoin de différer les mises à jour de rendu, de sorte que React les exécute de façon asynchrone peu après avoir reflété la mise à jour à l’écran.  (Dans les rares cas où vous avez besoin qu’un effet suspende l’affichage, par exemple pour mesurer et positionner une infobulle, préférez <code class="gatsby-code-text">useLayoutEffect</code>.)</p>
<p>Ceci dit, le fonction de <em>nettoyage</em> de l’effet, lorsqu’elle existe, s’exécutait de façon synchrone en React 16.  Nous avons pu constater que, comme pour la méthode synchrone <code class="gatsby-code-text">componentWillUnmount</code> sur les composants à base de classes, c’était loin d’être idéal pour les applis d’une certaine taille, car ça ralentissait les transitions entre écrans massifs (ex. bascule entre onglets).</p>
<p><strong>Dans React 17, la fonction de nettoyage d’effet s’exécute elle aussi de façon asynchrone ; par exemple, si le composant est en cours de démontage, le nettoyage aura lieu <em>après</em> que l’écran aura été mis à jour.</strong></p>
<p>Ça reflète mieux la façon dont les effets eux-mêmes sont exécutés.  Dans les rares cas où vous souhaiteriez dépendre d’une exécution synchrone, vous pouvez utiliser plutôt <code class="gatsby-code-text">useLayoutEffect</code>.</p>
<blockquote>
<p>Remarque</p>
<p>Vous vous demandez peut-être si ça signifie que vous ne pourrez plus corriger les avertissements relatifs à <code class="gatsby-code-text">setState</code> sur les composants démontés.  Ne vous inquiétez pas : React vérifie spécifiquement ce cas de figure, et <em>ne déclenche pas</em> les avertissements relatifs à <code class="gatsby-code-text">setState</code> dans le bref intervalle entre le démontage et le nettoyage.  <strong>Ainsi le code de nettoyage annulant les requêtes réseau ou horloges périodiques pourra presque toujours rester inchangé.</strong></p>
</blockquote>
<p>Qui plus est, React 17 exécute les fonctions de nettoyage dans le même ordre que leurs effets, en fonction de leur position dans l’arbre.  Auparavant, cet ordre pouvait parfois différer.</p>
<h4 id="potential-issues"><a href="#potential-issues" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Problèmes potentiels </h4>
<p>Ce changement n’a cassé que quelques-uns de nos composants, même si les bibliothèques réutilisables auront peut-être besoin de tester son impact de façon plus poussée.  Un exemple de code problématique pourrait ressembler à ceci :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token function">useEffect</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  someRef<span class="token punctuation">.</span>current<span class="token punctuation">.</span><span class="token function">someSetupMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
    someRef<span class="token punctuation">.</span>current<span class="token punctuation">.</span><span class="token function">someCleanupMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Le souci vient du fait que <code class="gatsby-code-text">someRef.current</code> est modifiable, de sorte qu’avant que la fonction de nettoyage soit exécutée, il risque d’avoir été mis à <code class="gatsby-code-text">null</code>.  La solution consisterait à capturer toute valeur pertinente modifiable <em>au sein</em> de l’effet :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token function">useEffect</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> instance <span class="token operator">=</span> someRef<span class="token punctuation">.</span>current<span class="token punctuation">;</span>
  instance<span class="token punctuation">.</span><span class="token function">someSetupMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
    instance<span class="token punctuation">.</span><span class="token function">someCleanupMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Nous n’anticipons pas de gros problèmes de ce type parce que <a href="https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks" target="_blank" rel="nofollow noopener noreferrer">notre règle d’analyse statique <code class="gatsby-code-text">eslint-plugin-react-hooks/exhaustive-deps</code></a> (assurez-vous de l’utiliser !) a toujours averti de ce type de scénario.</p>
<h3 id="consistent-errors-for-returning-undefined"><a href="#consistent-errors-for-returning-undefined" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Des erreurs plus cohérentes lorsqu’on renvoie <code class="gatsby-code-text">undefined</code> </h3>
<p>Jusqu’à React 16 inclus, renvoyer <code class="gatsby-code-text">undefined</code> a toujours produit une erreur :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">function</span> <span class="token function">Button</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token comment">// Erreur : `render` n’a rien renvoyé</span>
<span class="token punctuation">}</span></code></pre></div>
<p>C’est en partie parce qu’il est facile de renvoyer <code class="gatsby-code-text">undefined</code> par accident :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">function</span> <span class="token function">Button</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// On a oublié d’écrire un `return`, du coup ce composant renvoie `undefined`.</span>
  <span class="token comment">// React en fait une erreur plutôt que de passer ça sous silence.</span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token punctuation">/></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Jusqu’ici, React procédait ainsi pour les composants à base de classes et les fonctions composants, mais ne vérifiait pas les valeurs renvoyées par les composants produits par <code class="gatsby-code-text">forwardRef</code> et <code class="gatsby-code-text">memo</code>.  C’était dû à une erreur dans son code.</p>
<p><strong>Dans React 17, le comportement des composants produits par <code class="gatsby-code-text">forwardRef</code> et <code class="gatsby-code-text">memo</code> est cohérent avec celui des fonctions composants et composants à base de classe. Renvoyer <code class="gatsby-code-text">undefined</code> y constituera une erreur.</strong></p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">let</span> Button <span class="token operator">=</span> <span class="token function">forwardRef</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token comment">// On a oublié d’écrire un `return`, du coup ce composant renvoie `undefined`.</span>
  <span class="token comment">// React 17 en fait une erreur plutôt que de passer ça sous silence.</span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token punctuation">/></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> Button <span class="token operator">=</span> <span class="token function">memo</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token comment">// On a oublié d’écrire un `return`, du coup ce composant renvoie `undefined`.</span>
  <span class="token comment">// React 17 en fait une erreur plutôt que de passer ça sous silence.</span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token punctuation">/></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Dans les cas où vous souhaitez intentionnellement ne rien renvoyer, renvoyez plutôt <code class="gatsby-code-text">null</code>.</p>
<h3 id="native-component-stacks"><a href="#native-component-stacks" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Piles de composants natives </h3>
<p>Lorsque vous levez une erreur dans le navigateur, celui-ci vous donne une trace de pile <em>(stack trace, NdT)</em> avec des noms et emplacements de fonctions JavaScript.  Seulement voilà, ces traces de piles sont souvent insuffisantes pour diagnostiquer le problème, parce que la hiérarchie de l’arbre React est tout aussi importante.  Vous voulez savoir non seulement qu’un <code class="gatsby-code-text">Button</code> a levé une erreur, mais <em>où ce <code class="gatsby-code-text">Button</code> figure dans l’arbre React</em>.</p>
<p>Pour remédier à ça, React 16 a commencé à afficher des « piles de composants » lorsque vous rencontrez une erreur.  Celles-ci n’avaient toutefois pas tous les avantages des traces de piles JavaScript natives.  En particulier, vous ne pouviez pas cliquer dessus dans la console parce que React ne savait pas où la fonction était déclarée dans votre code source.  Qui plus est, elles étaient <a href="https://github.com/facebook/react/issues/12757" target="_blank" rel="nofollow noopener noreferrer">globalement inexploitables en production</a>.  Contrairement aux traces de piles du JavaScript minifié, qui peuvent automatiquement être transformées vers leurs noms et positions natives grâce à une <em>sourcemap</em>, les piles de composants React nous forçaient à choisir entre avoir des piles en production ou améliorer la taille de nos <em>bundles</em>.</p>
<p><strong>Dans React 17, les piles de composants sont générées par un mécanisme différent qui les agrège aux traces de piles JavaScript natives.  Vous pouvez ainsi bénéficier de traces de piles avec composants React pleinement descriptives, même dans un environnement de production.</strong></p>
<p>Pour y parvenir, React suit une approche assez inorthodoxe.  Les navigateurs ne fournissent pas pour le moment un moyen de récupérer le cadre de pile d’une fonction (dont son fichier source et sa position à l’intérieur).  Aussi, lorsque React détecte une erreur, il va désormais <em>reconstruire</em> sa pile de composants en levant (et rattrapant) une erreur temporaire au sein de chaque composant ancêtre, lorsque c’est possible.  Ça dégrade très légèrement la performance des erreurs, mais ça n’arrive qu’une fois par type de composant.</p>
<p>Si vous êtes curieux·se, vous pouvez en apprendre davantage dans <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">cette <em>pull request</em></a>, mais pour l’essentiel le détail du mécanisme ne devrait en rien affecter votre code.  De votre point de vue, la nouveauté vient de ce que les piles de composants sont désormais cliquables (puisqu’elles se reposent sur les traces de piles natives du navigateur), et que vous pouvez les décoder en production comme pour n’importe quelle erreur JavaScript classique.</p>
<p>On rompt ici la compatibilité ascendante parce que, pour que ça fonctionne, React doit ré-exécuter une partie de certaines des fonctions composants (et des constructeurs de composants à base de classe) plus haut dans la pile après qu’une erreur est survenue.  Dans la mesure où les fonctions de rendu et les constructeurs de classes ne devraient pas contenir d’effets de bord (un point important pour le rendu côté serveur également), ça ne devrait pas poser de problème en pratique.</p>
<h3 id="removing-private-exports"><a href="#removing-private-exports" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Retrait des exports privés </h3>
<p>Pour finir, la dernière rupture notable de compatibilité ascendante vient de ce que nous avons retiré quelques éléments internes de React qui étaient jusqu’ici accessibles par du code tiers.  En particulier, <a href="https://github.com/necolas/react-native-web" target="_blank" rel="nofollow noopener noreferrer">React Native for Web</a> dépendait de certains éléments internes du système de gestion d’événements, mais ce couplage était fragile et avait tendance à planter.</p>
<p><strong>Dans React 17, ces exports privés ont été retirés.  Pour autant qu’on sache, React Native for Web était le seul projet qui s’en servait, et ils ont déjà migré vers une approche qui ne repose plus dessus.</strong></p>
<p>Ça signifie que les anciennes versions de React Native for Web ne seront pas compatibles avec React 17, mais les versions plus récentes fonctionneront très bien.  En pratique, ça ne change pas grand-chose parce que React Native for Web avait de toutes façons besoin de sortir de nouvelles versions pour s’adapter aux modifications internes de React.</p>
<p>Qui plus est, nous avons retiré les méthodes utilitaires <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code>.  Elles n’avaient jamais été documentées, ne faisaient pas tout à fait ce que leur nom laissait entendre, et ne fonctionnaient plus suite aux évolutions récentes du système de gestion d’événements.  Si vous cherchez un moyen pratique de déclencher des événements natifs du navigateur dans vos tests, jetez plutôt un coup d’œil à <a href="https://testing-library.com/docs/dom-testing-library/api-events" target="_blank" rel="nofollow noopener noreferrer">React Testing Library</a>.</p>
<h2 id="installation"><a href="#installation" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Installation </h2>
<p>Nous vous encourageons à essayer dès que vous le pourrez React 17.0 Release Candidate et à <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">nous faire part de tout problème</a> que vous pourriez rencontrer pendant votre migration. <strong>Gardez à l’esprit qu’une version <em>release candidate</em> est plus susceptible de contenir des bugs qu’une version stable, aussi ne la déployez pas en production pour le moment.</strong></p>
<p>Pour installer React 17 RC avec npm, exécutez :</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">npm</span> <span class="token function">install</span> react@17.0.0-rc.3 react-dom@17.0.0-rc.3</code></pre></div>
<p>Pour installer React 17 RC avec Yarn, exécutez :</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">yarn</span> <span class="token function">add</span> react@17.0.0-rc.3 react-dom@17.0.0-rc.3</code></pre></div>
<p>Nous fournissons aussi des builds UMD de React via un CDN :</p>
<div class="gatsby-highlight" data-language="html"><pre class="gatsby-code-html"><code class="gatsby-code-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">crossorigin</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>https://unpkg.com/react@17.0.0-rc.3/umd/react.production.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">crossorigin</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>https://unpkg.com/react-dom@17.0.0-rc.3/umd/react-dom.production.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre></div>
<p>Référez-vous à la documentation pour des <a href="/docs/installation.html">instructions détaillées d’installation</a>.</p>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li>Ajoute <code class="gatsby-code-text">react/jsx-runtime</code> et <code class="gatsby-code-text">react/jsx-dev-runtime</code> pour la <a href="https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154-https-githubcom-babel-babel-pull-11154" target="_blank" rel="nofollow noopener noreferrer">nouvelle transformation JSX</a>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> dans <a href="https://github.com/facebook/react/pull/18299" target="_blank" rel="nofollow noopener noreferrer">#18299</a>)</li>
<li>Construit des piles de composants à partir des traces de piles natives. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">#18561</a>)</li>
<li>Permet de préciser <code class="gatsby-code-text">displayName</code> dans le contexte pour des piles améliorées. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> dans <a href="https://github.com/facebook/react/pull/18224" target="_blank" rel="nofollow noopener noreferrer">#18224</a>)</li>
<li>Évite les fuites de <code class="gatsby-code-text">'use strict'</code> dans les bundles UMD. (<a href="https://github.com/koba04" target="_blank" rel="nofollow noopener noreferrer">@koba04</a> dans <a href="https://github.com/facebook/react/pull/19614" target="_blank" rel="nofollow noopener noreferrer">#19614</a>)</li>
<li>Cesse d‘utiliser <code class="gatsby-code-text">fb.me</code> pour les redirections. (<a href="https://github.com/cylim" target="_blank" rel="nofollow noopener noreferrer">@cylim</a> dans <a href="https://github.com/facebook/react/pull/19598" target="_blank" rel="nofollow noopener noreferrer">#19598</a>)</li>
</ul>
<h3 id="react-dom"><a href="#react-dom" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM </h3>
<ul>
<li>Délègue les événements à la racine plutôt que sur <code class="gatsby-code-text">document</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/18195" target="_blank" rel="nofollow noopener noreferrer">#18195</a> et <a href="https://github.com/facebook/react/pulls?q=is%3Apr+author%3Atrueadm+modern+event+is%3Amerged" target="_blank" rel="nofollow noopener noreferrer">d’autres</a>)</li>
<li>Nettoie tous les effets avant d’exécuter les effets suivants. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/17947" target="_blank" rel="nofollow noopener noreferrer">#17947</a>)</li>
<li>Exécute les fonctions de nettoyage de <code class="gatsby-code-text">useEffect</code> de façon asynchrone. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/17925" target="_blank" rel="nofollow noopener noreferrer">#17925</a>)</li>
<li>Utilise les <code class="gatsby-code-text">focusin</code> et <code class="gatsby-code-text">focusout</code> du navigateur pour <code class="gatsby-code-text">onFocus</code> et <code class="gatsby-code-text">onBlur</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/19186" target="_blank" rel="nofollow noopener noreferrer">#19186</a>)</li>
<li>Exploite la phase de capture du navigateur pour tous les événements <code class="gatsby-code-text">Capture</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/19221" target="_blank" rel="nofollow noopener noreferrer">#19221</a>)</li>
<li>Cesse de simuler le bouillonnement pour l’événement <code class="gatsby-code-text">onScroll</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/19464" target="_blank" rel="nofollow noopener noreferrer">#19464</a>)</li>
<li>Lève une exception si un composant <code class="gatsby-code-text">forwardRef</code> ou <code class="gatsby-code-text">memo</code> renvoie <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Retire le recyclage des événements. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/18969" target="_blank" rel="nofollow noopener noreferrer">#18969</a>)</li>
<li>Cesse d’exposer des éléments internes que React Native for Web n’utilisera plus. (<a href="https://github.com/necolas" target="_blank" rel="nofollow noopener noreferrer">@necolas</a> dans <a href="https://github.com/facebook/react/pull/18483" target="_blank" rel="nofollow noopener noreferrer">#18483</a>)</li>
<li>Attache tous les gestionnaires d’événements connus lors du montage de la racine. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/19659" target="_blank" rel="nofollow noopener noreferrer">#19659</a>)</li>
<li>Désactive <code class="gatsby-code-text">console</code> lors de la seconde passe de rendu du mode DEV. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>Déprécie l’API non documentée et déroutante <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/13407" target="_blank" rel="nofollow noopener noreferrer">#13407</a>)</li>
<li>Renomme les champs privés utilisés par des éléments internes. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/18377" target="_blank" rel="nofollow noopener noreferrer">#18377</a>)</li>
<li>Cesse d’appeler l’API User Timing en développement. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/18417" target="_blank" rel="nofollow noopener noreferrer">#18417</a>)</li>
<li>Désactive la console lors du rendu répété du mode strict. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>En mode strict, fait le double rendu des composants sans les Hooks. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> dans <a href="https://github.com/facebook/react/pull/18430" target="_blank" rel="nofollow noopener noreferrer">#18430</a>)</li>
<li>Permet l’appel de <code class="gatsby-code-text">ReactDOM.flushSync</code> au sein des méthodes de cycle de vie (avec avertissement). (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18759" target="_blank" rel="nofollow noopener noreferrer">#18759</a>)</li>
<li>Ajoute la propriété <code class="gatsby-code-text">code</code> sur les objets d’événements clavier. (<a href="https://github.com/bl00mber" target="_blank" rel="nofollow noopener noreferrer">@bl00mber</a> dans <a href="https://github.com/facebook/react/pull/18287" target="_blank" rel="nofollow noopener noreferrer">#18287</a>)</li>
<li>Ajoute la propriété <code class="gatsby-code-text">disableRemotePlayback</code> aux éléments <code class="gatsby-code-text">video</code>. (<a href="https://github.com/tombrowndev" target="_blank" rel="nofollow noopener noreferrer">@tombrowndev</a> dans <a href="https://github.com/facebook/react/pull/18619" target="_blank" rel="nofollow noopener noreferrer">#18619</a>)</li>
<li>Ajoute la propriété <code class="gatsby-code-text">enterKeyHint</code> aux éléments <code class="gatsby-code-text">input</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> dans <a href="https://github.com/facebook/react/pull/18634" target="_blank" rel="nofollow noopener noreferrer">#18634</a>)</li>
<li>Avertit de l’absence de <code class="gatsby-code-text">value</code> sur les <code class="gatsby-code-text">&lt;Context.Provider></code>. (<a href="https://github.com/charlie1404" target="_blank" rel="nofollow noopener noreferrer">@charlie1404</a> dans <a href="https://github.com/facebook/react/pull/19054" target="_blank" rel="nofollow noopener noreferrer">#19054</a>)</li>
<li>Avertit lorsque les composants <code class="gatsby-code-text">memo</code> ou <code class="gatsby-code-text">forwardRef</code> renvoient <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Améliore le message d’erreur des mises à jour invalides. (<a href="https://github.com/JoviDeCroock" target="_blank" rel="nofollow noopener noreferrer">@JoviDeCroock</a> dans <a href="https://github.com/facebook/react/pull/18316" target="_blank" rel="nofollow noopener noreferrer">#18316</a>)</li>
<li>Exclut les <code class="gatsby-code-text">forwardRef</code> et <code class="gatsby-code-text">memo</code> des traces de piles. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18559" target="_blank" rel="nofollow noopener noreferrer">#18559</a>)</li>
<li>Améliore le message d’erreur lors de la bascule entre champs contrôlés et non contrôlés. (<a href="https://github.com/vcarl" target="_blank" rel="nofollow noopener noreferrer">@vcarl</a> dans <a href="https://github.com/facebook/react/pull/17070" target="_blank" rel="nofollow noopener noreferrer">#17070</a>)</li>
<li>Maintient <code class="gatsby-code-text">onTouchStart</code>, <code class="gatsby-code-text">onTouchMove</code>, et <code class="gatsby-code-text">onWheel</code> passifs. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/19654" target="_blank" rel="nofollow noopener noreferrer">#19654</a>)</li>
<li>Corrige le gel de <code class="gatsby-code-text">setState</code> en développement au sein d’un <code class="gatsby-code-text">&lt;iframe></code> fermé. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/19220" target="_blank" rel="nofollow noopener noreferrer">#19220</a>)</li>
<li>Corrige l’abandon de rendu des composants paresseux avec <code class="gatsby-code-text">defaultProps</code>. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> dans <a href="https://github.com/facebook/react/pull/18539" target="_blank" rel="nofollow noopener noreferrer">#18539</a>)</li>
<li>Corrige l’avertissement faux positif lorsque <code class="gatsby-code-text">dangerouslySetInnerHTML</code> est <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> dans <a href="https://github.com/facebook/react/pull/18676" target="_blank" rel="nofollow noopener noreferrer">#18676</a>)</li>
<li>Corrige les utilitaires de tests dotés d’une implémentation non standard de <code class="gatsby-code-text">require</code>. (<a href="https://github.com/just-boris" target="_blank" rel="nofollow noopener noreferrer">@just-boris</a> dans <a href="https://github.com/facebook/react/pull/18632" target="_blank" rel="nofollow noopener noreferrer">#18632</a>)</li>
<li>Corrige <code class="gatsby-code-text">onBeforeInput</code> pour ne plus signaler un <code class="gatsby-code-text">event.type</code> incorrect. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> dans <a href="https://github.com/facebook/react/pull/19561" target="_blank" rel="nofollow noopener noreferrer">#19561</a>)</li>
<li>Corrige <code class="gatsby-code-text">event.relatedTarget</code> signalé comme <code class="gatsby-code-text">undefined</code> dans Firefox. (<a href="https://github.com/claytercek" target="_blank" rel="nofollow noopener noreferrer">@claytercek</a> dans <a href="https://github.com/facebook/react/pull/19607" target="_blank" rel="nofollow noopener noreferrer">#19607</a>)</li>
<li>Corrige “unspecified error” dans IE11. (<a href="https://github.com/hemakshis" target="_blank" rel="nofollow noopener noreferrer">@hemakshis</a> dans <a href="https://github.com/facebook/react/pull/19664" target="_blank" rel="nofollow noopener noreferrer">#19664</a>)</li>
<li>Corrige le rendu dans une racine <em>shadow</em>. (<a href="https://github.com/Jack-Works" target="_blank" rel="nofollow noopener noreferrer">@Jack-Works</a> dans <a href="https://github.com/facebook/react/pull/15894" target="_blank" rel="nofollow noopener noreferrer">#15894</a>)</li>
<li>Corrige le polyfill <code class="gatsby-code-text">movementX/Y</code> avec des événements de capture. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/19672" target="_blank" rel="nofollow noopener noreferrer">#19672</a>)</li>
<li>Utilise la délégation pour les événements <code class="gatsby-code-text">onSubmit</code> et <code class="gatsby-code-text">onReset</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/19333" target="_blank" rel="nofollow noopener noreferrer">#19333</a>)</li>
<li>Améliore l’efficacité mémoire. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/18970" target="_blank" rel="nofollow noopener noreferrer">#18970</a>)</li>
</ul>
<h3 id="react-dom-server"><a href="#react-dom-server" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Server </h3>
<ul>
<li>Homogénéise les comportements de <code class="gatsby-code-text">useCallback</code> et <code class="gatsby-code-text">useMemo</code> pour le moteur de rendu côté serveur. (<a href="https://github.com/alexmckenley" target="_blank" rel="nofollow noopener noreferrer">@alexmckenley</a> dans <a href="https://github.com/facebook/react/pull/18783" target="_blank" rel="nofollow noopener noreferrer">#18783</a>)</li>
<li>Corrige la fuite d’état lorsqu’une fonction composant lève une exception. (<a href="https://github.com/pmaccart" target="_blank" rel="nofollow noopener noreferrer">@pmaccart</a> dans <a href="https://github.com/facebook/react/pull/19212" target="_blank" rel="nofollow noopener noreferrer">#19212</a>)</li>
</ul>
<h3 id="react-test-renderer"><a href="#react-test-renderer" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Test Renderer </h3>
<ul>
<li>Améliore le message d’erreur de <code class="gatsby-code-text">findByType</code>. (<a href="https://github.com/henryqdineen" target="_blank" rel="nofollow noopener noreferrer">@henryqdineen</a> dans <a href="https://github.com/facebook/react/pull/17439" target="_blank" rel="nofollow noopener noreferrer">#17439</a>)</li>
</ul>
<h3 id="concurrent-mode-experimental"><a href="#concurrent-mode-experimental" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Mode concurrent (expérimental) </h3>
<ul>
<li>Repense les heuristiques d’agrégation de priorités. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18796" target="_blank" rel="nofollow noopener noreferrer">#18796</a>)</li>
<li>Ajoute le préfixe <code class="gatsby-code-text">unstable_</code> aux API expérimentales. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Retire <code class="gatsby-code-text">unstable_discreteUpdates</code> et <code class="gatsby-code-text">unstable_flushDiscreteUpdates</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Retire l’argument <code class="gatsby-code-text">timeoutMs</code>. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/19703" target="_blank" rel="nofollow noopener noreferrer">#19703</a>)</li>
<li>Désactive le prérendu <code class="gatsby-code-text">&lt;div hidden /></code> au profit d’une future API de remplacement. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18917" target="_blank" rel="nofollow noopener noreferrer">#18917</a>)</li>
<li>Ajoute un Hook expérimental <code class="gatsby-code-text">unstable_useOpaqueIdentifier</code>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> dans <a href="https://github.com/facebook/react/pull/17322" target="_blank" rel="nofollow noopener noreferrer">#17322</a>)</li>
<li>Ajoute l’API expérimentale <code class="gatsby-code-text">unstable_startTransition</code>. (<a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a> dans <a href="https://github.com/facebook/react/pull/19696" target="_blank" rel="nofollow noopener noreferrer">#19696</a>)</li>
<li>L’utilisation de <code class="gatsby-code-text">act</code> dans un moteur de rendu de test ne purge plus les variations de secours Suspense. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18596" target="_blank" rel="nofollow noopener noreferrer">#18596</a>)</li>
<li>Utilise un timeout de rendu global pour CPU Suspense. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/19643" target="_blank" rel="nofollow noopener noreferrer">#19643</a>)</li>
<li>Efface le contenu racine existant avant le montage. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/18730" target="_blank" rel="nofollow noopener noreferrer">#18730</a>)</li>
<li>Corrige un bug dans les périmètres d’erreurs. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18265" target="_blank" rel="nofollow noopener noreferrer">#18265</a>)</li>
<li>Corrige un bug qui sautait des mises à jour dans un arbre suspendu. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18384" target="_blank" rel="nofollow noopener noreferrer">#18384</a> et <a href="https://github.com/facebook/react/pull/18457" target="_blank" rel="nofollow noopener noreferrer">#18457</a>)</li>
<li>Corrige un bug qui sautait des mises à jour en phase de rendu. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18537" target="_blank" rel="nofollow noopener noreferrer">#18537</a>)</li>
<li>Corrige un bug dans <code class="gatsby-code-text">SuspenseList</code>. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18412" target="_blank" rel="nofollow noopener noreferrer">#18412</a>)</li>
<li>Corrige un bug qui entraînait l’affichage trop tôt des variations de secours Suspense. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18411" target="_blank" rel="nofollow noopener noreferrer">#18411</a>)</li>
<li>Corrige un bug lié aux composants à base de classe dans une <code class="gatsby-code-text">SuspenseList</code>. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18448" target="_blank" rel="nofollow noopener noreferrer">#18448</a>)</li>
<li>Corrige un bug lié aux champs qui pouvait sauter des mises à jour. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> dans <a href="https://github.com/facebook/react/pull/18515" target="_blank" rel="nofollow noopener noreferrer">#18515</a> et <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18535" target="_blank" rel="nofollow noopener noreferrer">#18535</a>)</li>
<li>Corrige un bug qui gelait des variations de secours Suspense.  (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18663" target="_blank" rel="nofollow noopener noreferrer">#18663</a>)</li>
<li>Ne plus élaguer la fin d’une SuspenseList lors de l’hydratation. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18854" target="_blank" rel="nofollow noopener noreferrer">#18854</a>)</li>
<li>Corrige un bug dans <code class="gatsby-code-text">useMutableSource</code> qui pouvait survenir lorsque <code class="gatsby-code-text">getSnapshot</code> changeait. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/18297" target="_blank" rel="nofollow noopener noreferrer">#18297</a>)</li>
<li>Corrige un bug de déchirement dans <code class="gatsby-code-text">useMutableSource</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/18912" target="_blank" rel="nofollow noopener noreferrer">#18912</a>)</li>
<li>Avertit lors d’un appel de setState hors du rendu mais avant la phase de commit. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/18838" target="_blank" rel="nofollow noopener noreferrer">#18838</a>)</li>
</ul>]]></description><link>https://fr.reactjs.org/blog/2020/08/10/react-v17-rc.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2020/08/10/react-v17-rc.html</guid><pubDate>Mon, 10 Aug 2020 00:00:00 GMT</pubDate></item><item><title><![CDATA[React v16.13.0]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Nous sortons aujourd’hui React 16.13.0.  Cette version contient des correctifs et de nouveaux avertissements de dépréciation qui nous aident à préparer le terrain pour une future version majeure.</p>
<h2 id="new-warnings"><a href="#new-warnings" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Nouveaux avertissements </h2>
<h3 id="warnings-for-some-updates-during-render"><a href="#warnings-for-some-updates-during-render" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Avertissement sur certaines mises à jour lors du rendu </h3>
<p>Un composant React ne devrait pas causer d’effet de bord dans d’autres composants lors de son rendu.</p>
<p>Nous autorisons l’appel de <code class="gatsby-code-text">setState</code> lors du rendu, mais <a href="/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops">uniquement sur <em>le même composant</em></a>. Si, lors du rendu, vous appelez <code class="gatsby-code-text">setState</code> sur un autre composant, vous verrez désormais l’avertissement suivant :</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">Warning: Cannot update a component from inside the function body of a different component.</code></pre></div>
<p><em>(« Avertissement : impossible de mettre à jour un composant depuis le corps de fonction d’un autre composant. »)</em></p>
<p><strong>Cet avertissement vous aidera à détecter des bugs applicatifs résultant de modifications involontaires d’état.</strong>  Dans les rares cas où vous voudriez effectivement modifier l’état d’un autre composant suite à votre rendu, vous pouvez enrober l’appel à <code class="gatsby-code-text">setState</code> au sein d’un <code class="gatsby-code-text">useEffect</code>.</p>
<h3 id="warnings-for-conflicting-style-rules"><a href="#warnings-for-conflicting-style-rules" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Avertissement sur conflits de propriétés CSS </h3>
<p>Lors de l’application dynamique d’un <code class="gatsby-code-text">style</code> contenant des versions concises et spécifiques de propriétés CSS, certaines combinaisons de mises à jour peuvent aboutir à des incohérences de style. Par exemple :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>toggle <span class="token operator">?</span>
  <span class="token punctuation">{</span> <span class="token literal-property property">background</span><span class="token operator">:</span> <span class="token string">'blue'</span><span class="token punctuation">,</span> <span class="token literal-property property">backgroundColor</span><span class="token operator">:</span> <span class="token string">'red'</span> <span class="token punctuation">}</span> <span class="token operator">:</span>
  <span class="token punctuation">{</span> <span class="token literal-property property">backgroundColor</span><span class="token operator">:</span> <span class="token string">'red'</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token plain-text">
  ...
</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre></div>
<p>Vous vous attendez alors sans doute à ce que la <code class="gatsby-code-text">&lt;div></code> ait un arrière-plan rouge, quelle que soit la valeur de <code class="gatsby-code-text">toggle</code>.  Et pourtant, en faisant alterner la valeur de <code class="gatsby-code-text">toggle</code> entre <code class="gatsby-code-text">true</code> et <code class="gatsby-code-text">false</code>, la couleur d’arrière-plan démarre à <code class="gatsby-code-text">red</code> puis alterne entre <code class="gatsby-code-text">transparent</code> et <code class="gatsby-code-text">blue</code>, <a href="https://codesandbox.io/s/serene-dijkstra-dr0vev" target="_blank" rel="nofollow noopener noreferrer">comme l’illustre cette démo</a>.</p>
<p><strong>React détecte désormais les conflits de propriétés CSS et émet un avertissement.</strong>  Pour corriger ce problème, ne mélangez pas des syntaxes concises et spécifiques pour la même propriété CSS dans la <em>prop</em> <code class="gatsby-code-text">style</code>.</p>
<h3 id="warnings-for-some-deprecated-string-refs"><a href="#warnings-for-some-deprecated-string-refs" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Avertissement sur certaines refs textuelles dépréciées </h3>
<p><a href="/docs/refs-and-the-dom.html#legacy-api-string-refs">Les refs textuelles sont une ancienne API</a> dont nous déconseillons l’emploi et qui sera dépréciée un jour :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>myRef<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span></code></pre></div>
<p>(Ne pas confondre les refs textuelles avec les refs en général, qui <strong>restent elles totalement prises en charge</strong>.)</p>
<p>À l’avenir, nous fournirons un script automatisé (un “codemod”) pour migrer votre code afin qu’il ne recoure plus à des refs textuelles.  Néanmoins, certains cas isolés ne peuvent être migrés automatiquement.  Cette version ajoute un nouvel avertissement <strong>uniquement pour ces cas-là</strong>, avant que nous procédions à leur dépréciation.</p>
<p>Par exemple, cet avertissement sera déclenché si vous utilisez des refs textuelles en conjonction avec une approche à base de <em>prop</em> de rendu <em>(render prop, NdT)</em> :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">class</span> <span class="token class-name">ClassWithRenderProp</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>
  <span class="token function">componentDidMount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">doSomething</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>refs<span class="token punctuation">.</span>myRef<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>props<span class="token punctuation">.</span><span class="token function">children</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">ClassParent</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>
  <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token punctuation">(</span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">ClassWithRenderProp</span></span><span class="token punctuation">></span></span><span class="token plain-text">
        </span><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>myRef<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">}</span><span class="token plain-text">
      </span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">ClassWithRenderProp</span></span><span class="token punctuation">></span></span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Ce type de code entraîne généralement des bugs. (Vous vous attendez peut-être à ce que la ref soit disponible dans <code class="gatsby-code-text">ClassParent</code>, mais au lieu de ça elle est placée sur <code class="gatsby-code-text">ClassWithRenderProp</code>).</p>
<p><strong>Vous n’avez très probablement pas besoin de ce type de code.</strong>  Si vous êtes pourtant volontairement dans un tel cas, utilisez plutôt <a href="/docs/refs-and-the-dom.html#creating-refs"><code class="gatsby-code-text">React.createRef()</code></a> :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">class</span> <span class="token class-name">ClassWithRenderProp</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>
  myRef <span class="token operator">=</span> React<span class="token punctuation">.</span><span class="token function">createRef</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">componentDidMount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">doSomething</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>myRef<span class="token punctuation">.</span>current<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>props<span class="token punctuation">.</span><span class="token function">children</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>myRef<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">ClassParent</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>
  <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token punctuation">(</span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">ClassWithRenderProp</span></span><span class="token punctuation">></span></span><span class="token plain-text">
        </span><span class="token punctuation">{</span><span class="token parameter">myRef</span> <span class="token operator">=></span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">ref</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>myRef<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">}</span><span class="token plain-text">
      </span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">ClassWithRenderProp</span></span><span class="token punctuation">></span></span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre></div>
<blockquote>
<p>Remarque</p>
<p>Pour voir cet avertissement, vous aurez besoin d’avoir installé <a href="https://babeljs.io/docs/en/babel-plugin-transform-react-jsx-self" target="_blank" rel="nofollow noopener noreferrer">babel-plugin-transform-react-jsx-self</a> parmi vos plugins Babel.  Il ne doit être activé <em>que</em> en mode développement.</p>
<p>Si vous utilisez Create React App ou le preset “react” avec Babel 7+, ce plugin est déjà installé par défaut.</p>
</blockquote>
<h3 id="deprecating-reactcreatefactory"><a href="#deprecating-reactcreatefactory" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Dépréciation de <code class="gatsby-code-text">React.createFactory</code> </h3>
<p><a href="/docs/react-api.html#createfactory"><code class="gatsby-code-text">React.createFactory</code></a> est une ancienne fonction utilitaire servant à créer des éléments React.  Cette version ajoute un avertissement de dépréciation à son sujet.  Elle sera retirée dans une future version majeure.</p>
<p>Remplacez vos utilisations de <code class="gatsby-code-text">React.createFactory</code> par du JSX classique.  Une autre approche consiste à copier-coller cet utilitaire qui tient sur une ligne, ou le publier sous forme de bibliothèque :</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">let</span> <span class="token function-variable function">createFactory</span> <span class="token operator">=</span> <span class="token parameter">type</span> <span class="token operator">=></span> React<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">,</span> type<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Ça fera exactement la même chose.</p>
<h3 id="deprecating-reactdomunstable_createportal-in-favor-of-reactdomcreateportal"><a href="#deprecating-reactdomunstable_createportal-in-favor-of-reactdomcreateportal" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Dépréciation de <code class="gatsby-code-text">ReactDOM.unstable_createPortal</code> au profit de <code class="gatsby-code-text">ReactDOM.createPortal</code> </h3>
<p>Lorsque nous avons sorti React 16, l’API <code class="gatsby-code-text">createPortal</code> est devenue officielle.</p>
<p>Cependant, nous avons continué à autoriser le recours à son nom temporaire <code class="gatsby-code-text">unstable_createPortal</code> afin de permettre à certaines bibliothèques l’ayant adopté de continuer à fonctionner.  Nous déprécions désormais ce nom antérieur.  Utilisez <code class="gatsby-code-text">createPortal</code> directement au lieu de <code class="gatsby-code-text">unstable_createPortal</code>.  La signature est exactement la même.</p>
<h2 id="other-improvements"><a href="#other-improvements" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Autres améliorations </h2>
<h3 id="component-stacks-in-hydration-warnings"><a href="#component-stacks-in-hydration-warnings" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Traces de piles des composants dans les avertissements de réhydratation </h3>
<p>React ajoute des traces de piles de composants à ses avertissements de développement, ce qui permet aux développeurs d’isoler les bugs et de déboguer leurs programmes.  Cette version ajoute ces traces de piles de composants à divers avertissements de développement qui n’en bénéficiaient pas jusqu’ici.  Prenez par exemple cet avertissement de réhydratation dans les versions précédentes :</p>
<p>
  <a
    class="gatsby-resp-image-link"
    href="/static/20bd06e254e7ad32aa007a59a41d1e65/61583/hydration-warning-before.png"
    style="display: block"
    target="_blank"
    rel="noopener"
  >
  
  <span
    class="gatsby-resp-image-wrapper"
    style="position: relative; display: block;  max-width: 840px; margin-left: auto; margin-right: auto;"
  >
    <span
      class="gatsby-resp-image-background-image"
      style="padding-bottom: 7.142857142857142%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAYAAADeko4lAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAPUlEQVQI1zXHQQ6AIAxEUe5/0FIQ0YSkGBb9xhQXkzc/Lcl4KbgqLoLXGv9o4d+f7Qxt7hnMB7tuuiprDF4Tqkyb/eSbCwAAAABJRU5ErkJggg=='); background-size: cover; display: block;"
    >
      <img
        class="gatsby-resp-image-image"
        style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;"
        alt="Capture d’écran d’un avertissement en console, qui indique juste la nature de la discordance de réhydratation : « Avertissement : le HTML renvoyé par le serveur aurait dû contenir un div correspondant dans le div. »"
        title=""
        src="/static/20bd06e254e7ad32aa007a59a41d1e65/1e088/hydration-warning-before.png"
        srcset="/static/20bd06e254e7ad32aa007a59a41d1e65/65ed1/hydration-warning-before.png 210w,
/static/20bd06e254e7ad32aa007a59a41d1e65/d10fb/hydration-warning-before.png 420w,
/static/20bd06e254e7ad32aa007a59a41d1e65/1e088/hydration-warning-before.png 840w,
/static/20bd06e254e7ad32aa007a59a41d1e65/78612/hydration-warning-before.png 1260w,
/static/20bd06e254e7ad32aa007a59a41d1e65/61583/hydration-warning-before.png 1616w"
        sizes="(max-width: 840px) 100vw, 840px"
      />
    </span>
  </span>
  
  </a>
    </p>
<p>Bien qu’il signale une erreur dans le code, la cause de l’erreur n’est pas claire, ainsi que la conduite à adopter.  Cette version ajoute une trace de pile de composants à l’avertissement, ce qui donne un affichage ressemblant à celui-ci :</p>
<p>
  <a
    class="gatsby-resp-image-link"
    href="/static/abf3b580867e79d5f377330842bb6522/d3d45/hydration-warning-after.png"
    style="display: block"
    target="_blank"
    rel="noopener"
  >
  
  <span
    class="gatsby-resp-image-wrapper"
    style="position: relative; display: block;  max-width: 840px; margin-left: auto; margin-right: auto;"
  >
    <span
      class="gatsby-resp-image-background-image"
      style="padding-bottom: 16.19047619047619%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAlUlEQVQI103OTQrCMBiE4d7/Vj1AddGdFiIoTdO0UTE/UpvvlVDQLp7FDAxM9ek1+XYjXy5Id+atFEkpSi/GkAutycNAtnbLL/8jPpCc4641y+NJJdOMtC3UNTQNqWnwhyNr10GvwYwwWrDTn7vvPMjTzDJaZHZUa0hgDHI6IdcrTGXgtq4oL2JCQtwJfz5AiBAjhMAXwerkhoKdWqMAAAAASUVORK5CYII='); background-size: cover; display: block;"
    >
      <img
        class="gatsby-resp-image-image"
        style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;"
        alt="Capture d’écran d’un avertissement en console, qui indique la nature de la discordance de réhydratation, mais avec la trace de pile de composants en plus : « Avertissement : le HTML renvoyé par le serveur aurait dû contenir un div correspondant dans le div (dans pages/index.js:4)... »"
        title=""
        src="/static/abf3b580867e79d5f377330842bb6522/1e088/hydration-warning-after.png"
        srcset="/static/abf3b580867e79d5f377330842bb6522/65ed1/hydration-warning-after.png 210w,
/static/abf3b580867e79d5f377330842bb6522/d10fb/hydration-warning-after.png 420w,
/static/abf3b580867e79d5f377330842bb6522/1e088/hydration-warning-after.png 840w,
/static/abf3b580867e79d5f377330842bb6522/78612/hydration-warning-after.png 1260w,
/static/abf3b580867e79d5f377330842bb6522/d3d45/hydration-warning-after.png 1614w"
        sizes="(max-width: 840px) 100vw, 840px"
      />
    </span>
  </span>
  
  </a>
    </p>
<p>On clarifie ainsi l’emplacement et l’origine du problème, ce qui vous aide à repérer le bug et à le corriger plus vite.</p>
<h3 id="notable-bugfixes"><a href="#notable-bugfixes" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Correctifs notables </h3>
<p>Cette version contient par ailleurs quelques améliorations notables :</p>
<ul>
<li>En mode strict de développement, React appelle les méthodes de cycle de vie deux fois pour éliminer au plus tôt les effets de bord involontaires.  Cette version étend ce comportement à <code class="gatsby-code-text">shouldComponentUpdate</code>.  Ça ne devrait guère affecter la plupart des bases de code, à moins que vous n’ayez des effets de bord dans <code class="gatsby-code-text">shouldComponentUpdate</code>.  Pour y remédier, déplacez le code des effets de bord dans <code class="gatsby-code-text">componentDidUpdate</code>.</li>
<li>En mode strict de développement, les avertissements relatifs à l’utilisation de l’ancienne API de contexte n’incluaient pas de traces de piles de composant.  Cette version les y ajoute.</li>
<li><code class="gatsby-code-text">onMouseEnter</code> ne se déclenche plus sur les éléments <code class="gatsby-code-text">&lt;button></code> désactivés.</li>
<li>ReactDOM n’exportait plus <code class="gatsby-code-text">version</code> depuis la sortie de la v16.  Cette version restaure l’export.  Nous déconseillons de vous en servir dans votre logique applicative, mais ça peut être utile pour déboguer des problèmes dus à des incohérences de versions, ou versions multiples, de ReactDOM dans une même page.</li>
</ul>
<p>Nous remercions tous les contributeurs qui nous ont aidé à repérer et corriger ces bugs et d’autres.  Vous pouvez consulter le journal complet des modifications <a href="#changelog">ci-après</a>.</p>
<h2 id="installation"><a href="#installation" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Installation </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<p>React v16.13.0 est disponible sur le référentiel npm.</p>
<p>Pour installer React 16 avec Yarn, exécutez :</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">yarn</span> <span class="token function">add</span> react@^16.13.0 react-dom@^16.13.0</code></pre></div>
<p>Pour installer React 16 avec npm, exécutez :</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token function">npm</span> <span class="token function">install</span> <span class="token parameter variable">--save</span> react@^16.13.0 react-dom@^16.13.0</code></pre></div>
<p>Nous fournissons aussi des builds de React sur un CDN :</p>
<div class="gatsby-highlight" data-language="html"><pre class="gatsby-code-html"><code class="gatsby-code-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">crossorigin</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>https://unpkg.com/react@16/umd/react.production.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">crossorigin</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>https://unpkg.com/react-dom@16/umd/react-dom.production.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre></div>
<p>Consultez la documentation pour des <a href="/docs/installation.html">instructions d’installation détaillées</a>.</p>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li>Avertir lorsqu’une ref textuelle est utilisée de façon incompatible avec un futur codemod (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> dans <a href="https://github.com/facebook/react/pull/17864" target="_blank" rel="nofollow noopener noreferrer">#17864</a>)</li>
<li>Déprécier <code class="gatsby-code-text">React.createFactory()</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/17878" target="_blank" rel="nofollow noopener noreferrer">#17878</a>)</li>
</ul>
<h3 id="react-dom"><a href="#react-dom" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM </h3>
<ul>
<li>Avertir lorsque des modifications à <code class="gatsby-code-text">style</code> risquent de causer des conflits inattendus (<a href="https://github.com/sophiebits" target="_blank" rel="nofollow noopener noreferrer">@sophiebits</a> dans <a href="https://github.com/facebook/react/pull/14181" target="_blank" rel="nofollow noopener noreferrer">#14181</a> et <a href="https://github.com/facebook/react/pull/18002" target="_blank" rel="nofollow noopener noreferrer">#18002</a>)</li>
<li>Avertir lorsqu’une fonction composant est mise à jour depuis la phase de rendu d’un autre composant (<a href="(https://github.com/acdlite)">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/17099" target="_blank" rel="nofollow noopener noreferrer">#17099</a>)</li>
<li>Déprécier <code class="gatsby-code-text">unstable_createPortal</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/17880" target="_blank" rel="nofollow noopener noreferrer">#17880</a>)</li>
<li>Corriger le déclenchement de <code class="gatsby-code-text">onMouseEnter</code> sur des boutons désactivés (<a href="https://github.com/AlfredoGJ" target="_blank" rel="nofollow noopener noreferrer">@AlfredoGJ</a> dans <a href="https://github.com/facebook/react/pull/17675" target="_blank" rel="nofollow noopener noreferrer">#17675</a>)</li>
<li>Appeler <code class="gatsby-code-text">shouldComponentUpdate</code> deux fois en développement <code class="gatsby-code-text">StrictMode</code> (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/17942" target="_blank" rel="nofollow noopener noreferrer">#17942</a>)</li>
<li>Ajouter la propriété <code class="gatsby-code-text">version</code> à ReactDOM (<a href="https://github.com/ealush" target="_blank" rel="nofollow noopener noreferrer">@ealush</a> dans <a href="https://github.com/facebook/react/pull/15780" target="_blank" rel="nofollow noopener noreferrer">#15780</a>)</li>
<li>Ne pas appeler le <code class="gatsby-code-text">toString()</code> de <code class="gatsby-code-text">dangerouslySetInnerHTML</code> (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/17773" target="_blank" rel="nofollow noopener noreferrer">#17773</a>)</li>
<li>Afficher les traces de piles de composants dans davantage d’avertissements (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/17922" target="_blank" rel="nofollow noopener noreferrer">#17922</a> et <a href="https://github.com/facebook/react/pull/17586" target="_blank" rel="nofollow noopener noreferrer">#17586</a>)</li>
</ul>
<h3 id="concurrent-mode-experimental"><a href="#concurrent-mode-experimental" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Mode concurrent (expérimental) </h3>
<ul>
<li>Avertir des utilisations problématiques de <code class="gatsby-code-text">ReactDOM.createRoot()</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/17937" target="_blank" rel="nofollow noopener noreferrer">#17937</a>)</li>
<li>Retirer les fonctions de rappel dans la signature de <code class="gatsby-code-text">ReactDOM.createRoot()</code> et ajouter des avertissements lorsque ces paramètres sont utilisés (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> dans <a href="https://github.com/facebook/react/pull/17916" target="_blank" rel="nofollow noopener noreferrer">#17916</a>)</li>
<li>Ne pas grouper les travaux Idle/Offscreen avec d’autres travaux (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/17456" target="_blank" rel="nofollow noopener noreferrer">#17456</a>)</li>
<li>Ajuster les heuristiques d’occupation CPU de <code class="gatsby-code-text">SuspenseList</code> (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/17455" target="_blank" rel="nofollow noopener noreferrer">#17455</a>)</li>
<li>Ajouter les priorités manquantes du plugin d’événements (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> dans <a href="https://github.com/facebook/react/pull/17914" target="_blank" rel="nofollow noopener noreferrer">#17914</a>)</li>
<li>Corriger la valeur incorrecte à <code class="gatsby-code-text">true</code> de <code class="gatsby-code-text">isPending</code> pendant la transition depuis l’intérieur d’un événement <code class="gatsby-code-text">input</code> (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/17382" target="_blank" rel="nofollow noopener noreferrer">#17382</a>)</li>
<li>Corriger la perte de mises à jour dans les composants enrobés par <code class="gatsby-code-text">React.memo</code> lorsqu’elles sont interrompues par des mises à jour à plus forte priorité (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> dans <a href="https://github.com/facebook/react/pull/18091" target="_blank" rel="nofollow noopener noreferrer">#18091</a>)</li>
<li>Ne pas avertir lors de la suspension au sein d’une priorité incorrecte (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> dans <a href="https://github.com/facebook/react/pull/17971" target="_blank" rel="nofollow noopener noreferrer">#17971</a>)</li>
<li>Corriger un bug au sein du repositionnement des mises à jour (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> et <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> dans <a href="https://github.com/facebook/react/pull/17560" target="_blank" rel="nofollow noopener noreferrer">#17560</a>, <a href="https://github.com/facebook/react/pull/17510" target="_blank" rel="nofollow noopener noreferrer">#17510</a>, <a href="https://github.com/facebook/react/pull/17483" target="_blank" rel="nofollow noopener noreferrer">#17483</a> et <a href="https://github.com/facebook/react/pull/17480" target="_blank" rel="nofollow noopener noreferrer">#17480</a>)</li>
</ul>]]></description><link>https://fr.reactjs.org/blog/2020/02/26/react-v16.13.0.html</link><guid isPermaLink="false">https://fr.reactjs.org/blog/2020/02/26/react-v16.13.0.html</guid><pubDate>Wed, 26 Feb 2020 00:00:00 GMT</pubDate></item></channel></rss>