<?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[A JavaScript library for building user interfaces]]></description><link>https://pt-br.reactjs.org</link><generator>GatsbyJS</generator><lastBuildDate>Fri, 28 Apr 2023 10:57:31 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://pt-br.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://pt-br.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://pt-br.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://pt-br.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://pt-br.reactjs.org/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.html</link><guid isPermaLink="false">https://pt-br.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://pt-br.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://pt-br.reactjs.org/blog/2022/03/29/react-v18.html</link><guid isPermaLink="false">https://pt-br.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://pt-br.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://pt-br.reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html</link><guid isPermaLink="false">https://pt-br.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://pt-br.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://pt-br.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://pt-br.reactjs.org/blog/2021/12/17/react-conf-2021-recap.html</link><guid isPermaLink="false">https://pt-br.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[O plano para o React 18]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://pt-br.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<blockquote>
<p>Atualizado em Nov. 15, 2021</p>
<p>O React 18 está agora em beta. Mais informações sobre o status da liberação estão <a href="https://github.com/reactwg/react-18/discussions/112" target="_blank" rel="nofollow noopener noreferrer">disponíveis na postagem do React 18 Working Group</a>.</p>
</blockquote>
<p>O time do React está animado para compartilhar algumas atualizações:</p>
<ol>
<li>Começamos a trabalhar no lançamento do React 18, que será nossa próxima versão principal.</li>
<li>Criamos um Grupo de Trabalho para preparar a comunidade para a adoção gradual de novos recursos no React 18.</li>
<li>Publicamos um Alpha do React 18 para que os autores de bibliotecas possam testá-lo e fornecer feedback.</li>
</ol>
<p>Essas atualizações são destinadas principalmente aos mantenedores de bibliotecas de terceiros. Se você está aprendendo, ensinando ou usando o React para criar aplicações voltadas para o usuário, pode seguramente ignorar este post. Mas você é bem vindo para acompanhar as discussões no Grupo de Trabalho React 18 se estiver curioso!</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>O que está chegando no React 18 </h2>
<p>Quando for lançado, o React 18 incluirá melhorias prontas para uso (como <a href="https://github.com/reactwg/react-18/discussions/21" target="_blank" rel="nofollow noopener noreferrer">lote automático</a>), novas APIs (como <a href="https://github.com/reactwg/react-18/discussions/41" target="_blank" rel="nofollow noopener noreferrer"><code class="gatsby-code-text">startTransition</code></a>) e um <a href="https://github.com/reactwg/react-18/discussions/37" target="_blank" rel="nofollow noopener noreferrer">novo renderizador de servidor de streaming</a> com suporte integrado para <code class="gatsby-code-text">React.lazy</code>.</p>
<p>Esses recursos são possíveis graças a um novo mecanismo opcional que estamos adicionando no React 18. É chamado de “renderização concorrente” e permite que o React prepare várias versões da UI ao mesmo tempo. Essa mudança ocorre principalmente nos bastidores, mas abre novas possibilidades para melhorar o desempenho real e percebido de sua aplicação.</p>
<p>Se você tem acompanhado nossa pesquisa sobre o futuro do React (não esperamos que você faça isso!), você pode ter ouvido falar de algo chamado “modo concorrente” ou que esse modo pode quebrar sua aplicação. Em resposta a este feedback da comunidade, reformulamos a estratégia de atualização para uma adoção gradual. Em vez de um “modo” tudo ou nada, a renderização concorrente só será habilitada para atualizações acionadas por um dos novos recursos. Na prática, isso significa que <strong>você poderá adotar o React 18 sem reescrever e experimentar os novos recursos em seu próprio ritmo.</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>Uma estratégia de adoção gradual </h2>
<p>Como a concorrência no React 18 é opcional, não há mudanças significativas fora da caixa no comportamento de componente. <strong>Você pode atualizar para o React 18 com o mínimo ou nenhuma alteração no código da aplicação, com um nível de esforço comparável a uma versão principal típica do React</strong>. Com base em nossa experiência na conversão de várias aplicações para React 18, esperamos que muitos usuários sejam capazes de atualizar em uma única tarde.</p>
<p>Enviamos com sucesso recursos concorrentes para dezenas de milhares de componentes no Facebook e, em nossa experiência, descobrimos que a maioria dos componentes do React “simplesmente funcionam” sem alterações adicionais. Estamos empenhados em garantir que esta seja uma atualização tranquila para toda a comunidade, então hoje estamos anunciando o Grupo de Trabalho React 18.</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>Trabalhando com a comunidade </h2>
<p>Estamos tentando algo novo para este lançamento: convidamos um painel de especialistas, desenvolvedores, autores de bibliotecas e educadores de toda a comunidade React para participar de nosso <a href="https://github.com/reactwg/react-18" target="_blank" rel="nofollow noopener noreferrer">Grupo de Trabalho React 18</a> para fornecer feedback, fazer perguntas e colaborar no lançamento. Não pudemos convidar todos que queríamos para este pequeno grupo inicial, mas se essa experiência funcionar, esperamos que haja mais no futuro!</p>
<p><strong>O objetivo do Grupo de Trabalho React 18 é preparar o ecossistema para uma adoção gradual e suave do React 18 por aplicações e bibliotecas existentes.</strong> O Grupo de Trabalho está hospedado em <a href="https://github.com/reactwg/react-18/discussions" target="_blank" rel="nofollow noopener noreferrer">GitHub Discussions</a> e está disponível para leitura do público. Os membros do grupo de trabalho podem deixar comentários, fazer perguntas e compartilhar ideias. O time principal também usará o repositório de discussões para compartilhar nossos resultados de pesquisa. Conforme a versão estável se aproxima, qualquer informação importante também será postada neste blog.</p>
<p>Para obter mais informações sobre como atualizar para o React 18 ou recursos adicionais sobre o lançamento, consulte a <a href="https://github.com/reactwg/react-18/discussions/4" target="_blank" rel="nofollow noopener noreferrer">postagem de anúncio do React 18</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>Acessando o Grupo de Trabalho React 18 </h2>
<p>Todos podem ler as discussões no <a href="https://github.com/reactwg/react-18" target="_blank" rel="nofollow noopener noreferrer">repositório Grupo de Trabalho React 18</a>.</p>
<p>Como esperamos um aumento inicial de interesse no Grupo de Trabalho, apenas membros convidados terão permissão para criar ou comentar nos tópicos. No entanto, os tópicos são totalmente visíveis ao público, para que todos tenham acesso às mesmas informações. Acreditamos que este é um bom balanço entre a criação de um ambiente produtivo para os membros do grupo de trabalho e manter a transparência com a comunidade em geral.</p>
<p>Como sempre, você pode enviar relatórios de bugs, perguntas e feedback geral para nosso <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">rastreador de problemas</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>Como experimentar o Alpha do React 18 hoje </h2>
<p>Novos alphas são <a href="https://github.com/reactwg/react-18/discussions/9" target="_blank" rel="nofollow noopener noreferrer">publicados regularmente para o npm usando a tag <code class="gatsby-code-text">@alpha</code></a>. Essas versões são criadas usando o commit mais recente de nosso repositório principal. Quando um recurso ou correção de bug é mesclado, ele aparecerá em um alpha no próximo dia útil.</p>
<p>Podem haver mudanças comportamentais ou de API significativas entre as versões alpha. Por favor lembre-se de que <strong>versões alpha não são recomendadas para aplicações de produção voltados para o usuário</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>Cronograma de lançamento projetado do React 18 </h2>
<p>Não temos uma data de lançamento específica agendada, mas esperamos que leve vários meses de feedback e iteração antes que o React 18 esteja pronto para a maioria das aplicações de produção.</p>
<ul>
<li>Biblioteca Alpha: disponível hoje</li>
<li>Beta Público: pelo menos vários meses</li>
<li>Release Candidate (RC): pelo menos várias semanas após o Beta</li>
<li>Disponibilidade Geral: pelo menos várias semanas após RC</li>
</ul>
<p>Mais detalhes sobre nosso cronograma de lançamento projetado estão <a href="https://github.com/reactwg/react-18/discussions/9" target="_blank" rel="nofollow noopener noreferrer">disponíveis no Grupo de Trabalho</a>. Publicaremos atualizações neste blog quando estivermos próximos de um lançamento público.</p>]]></description><link>https://pt-br.reactjs.org/blog/2021/06/08/the-plan-for-react-18.html</link><guid isPermaLink="false">https://pt-br.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[Apresentando Componentes React de tamanho zero no Servidor]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://pt-br.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>2020 foi um longo ano. Como está chegando ao fim, gostaríamos de compartilhar uma atualização especial de feriado em nossa pesquisa sobre <strong>Componentes React de tamanho zero no Servidor</strong>.</p>
<p>Para apresentar Componentes React no Servidor, nós preparamos uma palestra e uma demonstração. Se quiser, você pode conferir durante as férias ou mais tarde, quando o trabalho voltar no ano novo.</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>Componentes React no Servidor ainda estão em estudo e desenvolvimento.</strong> Nós estamos compartilhando esse trabalho com o espírito de transparência e para obter o feedback inicial da comunidade React. Haverá muito tempo para isso, então <strong>não sinta que você precisa se atualizar agora!</strong></p>
<p>Se você quiser conferir, recomendamos ir na seguinte ordem:</p>
<ol>
<li><strong>Assista à palestra</strong> para saber sobre Componentes React no Servidor e veja a demonstração.</li>
<li><strong><a href="http://github.com/reactjs/server-components-demo" target="_blank" rel="nofollow noopener noreferrer">Clone a demonstração disponível no GitHub</a></strong> para brincar com Componentes React no Servidor em seu computador.</li>
<li><strong><a href="https://github.com/reactjs/rfcs/pull/188" target="_blank" rel="nofollow noopener noreferrer">Leia o RFC (com a seção de Perguntas Frequentes no final)</a></strong> para uma análise técnica mais detalhada e para nos fornecer feedback.</li>
</ol>
<p>Nós estamos animados para ouvir vocês no RFC ou nas respostas do nosso <a href="https://twitter.com/reactjs" target="_blank" rel="nofollow noopener noreferrer">@reactjs</a> Twitter oficial. Boas festas, fique seguro e nos vemos ano que vem!</p>]]></description><link>https://pt-br.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html</link><guid isPermaLink="false">https://pt-br.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://pt-br.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Hoje, nós estamos lançando o React 17! Escrevemos longamente sobre o papel da versão React 17 e as mudanças que ele contém na <a href="/blog/2020/08/10/react-v17-rc.html">postagem do blog React 17 RC</a>. Este post é um breve resumo dele, então se você já leu o post RC, você pode pular este.</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>Sem novos recursos </h2>
<p>A versão React 17 é incomum porque não adiciona nenhum novo recurso voltado para o desenvolvedor. Em vez disso, este lançamento está focado principalmente em <strong>tornar mais fácil atualizar o próprio React</strong>.</p>
<p>Em particular, o React 17 é uma versão de “trampolim” que torna mais seguro incorporar uma árvore gerenciada por uma versão do React dentro de uma árvore gerenciada por uma versão diferente do React.</p>
<p>Também torna mais fácil incorporar o React a aplicativos desenvolvidos com outras tecnologias.</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>Upgrades Graduais </h2>
<p><strong>O React 17 permite atualizações graduais do React.</strong> Quando você atualiza do React 15 para o 16 (ou, desta vez, do React 16 para o 17), normalmente atualiza o aplicativo inteiro de uma vez. Isso funciona bem para muitos aplicativos. Mas pode se tornar cada vez mais desafiador se a base de código foi escrita há alguns anos e não é mantida ativamente. E embora seja possível usar duas versões do React na página, até o React 17 isso era frágil e causava problemas com eventos.</p>
<p>Estamos corrigindo muitos desses problemas com o React 17. Isso significa que <strong>quando React 18 e as próximas versões futuras forem lançadas, você terá mais opções</strong>. A primeira opção será atualizar todo o seu aplicativo de uma vez, como você pode ter feito antes. Mas você também terá a opção de atualizar seu aplicativo peça por peça. Por exemplo, você pode decidir migrar a maior parte do seu aplicativo para o React 18, mas manter algumas caixas de diálogo carregadas lentamente ou um sub-rota no React 17.</p>
<p>Isso não significa você <em>precise</em> fazer atualizações graduais. <strong>Para a maioria dos aplicativos, atualizar tudo de uma vez ainda é a melhor solução.</strong> Carregar duas versões do React - mesmo se uma delas for carregada lentamente sob demanda - ainda não é o ideal. No entanto, para aplicativos maiores que não são mantidos ativamente, faz sentido considerar essa opção, e o React 17 permite que esses aplicativos não sejam deixados para trás.</p>
<p>Nós preparamos um <a href="https://github.com/reactjs/react-gradual-upgrade-demo/" target="_blank" rel="nofollow noopener noreferrer">repositório de exemplo</a> demonstrando como carregar lentamente uma versão anterior do React, se necessário. Esta demonstração usa Create React App, mas deve ser possível seguir uma abordagem semelhante com qualquer outra ferramenta. Aceitamos demonstrações usando outras ferramentas como pull requests.</p>
<blockquote>
<p>Nota</p>
<p><strong>Adiamos outras mudanças</strong> até depois do React 17. O objetivo desta versão é permitir atualizações graduais. Se atualizar para React 17 fosse muito difícil, isso iria contra o seu propósito.</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>Mudanças na Delegação do Evento </h2>
<p>Para permitir atualizações graduais, precisamos fazer algumas mudanças no sistema de eventos React. O React 17 é um grande lançamento porque essas alterações são potencialmente prejudiciais. Você pode conferir nosso <a href="/docs/faq-versioning.html#breaking-changes">FAQ de versionamento</a> para saber mais sobre nosso compromisso com a estabilidade.</p>
<p>No React 17, o React não anexará mais manipuladores de eventos no nível do <code class="gatsby-code-text">documento</code> sob o hood. Em vez disso, ele os anexará ao contêiner root DOM no qual sua árvore React é renderizada:</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>No React 16 e anteriores, o React faria <code class="gatsby-code-text">document.addEventListener()</code> para a maioria dos eventos. React 17 ligará <code class="gatsby-code-text">rootNode.addEventListener()</code> sob o hood em vez disso.</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="Um diagrama que mostra como o React 17 anexa eventos aos roots em vez de ao documento"
        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>Nós confirmamos que <a href="https://github.com/facebook/react/issues/7094" target="_blank" rel="nofollow noopener noreferrer">numerosos</a> <a href="https://github.com/facebook/react/issues/8693" target="_blank" rel="nofollow noopener noreferrer">problemas</a> <a href="https://github.com/facebook/react/issues/12518" target="_blank" rel="nofollow noopener noreferrer">relatados</a> <a href="https://github.com/facebook/react/issues/13451" target="_blank" rel="nofollow noopener noreferrer">sobre</a> <a href="https://github.com/facebook/react/issues/4335" target="_blank" rel="nofollow noopener noreferrer">os</a> <a href="https://github.com/facebook/react/issues/1691" target="_blank" rel="nofollow noopener noreferrer">anos</a> <a href="https://github.com/facebook/react/issues/285#issuecomment-253502585" target="_blank" rel="nofollow noopener noreferrer">na</a> <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">nossa</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">rastreador</a> relacionadas à integração do React com o código não React foram corrigidas pelo novo comportamento.</p>
<p>Se você tiver problemas com essa mudança, <a href="/blog/2020/08/10/react-v17-rc.html#fixing-potential-issues">aqui está uma maneira comum de resolvê-los</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>Outras Mudanças Importantes </h2>
<p><a href="/blog/2020/08/10/react-v17-rc.html#other-breaking-changes">O post do blog React 17 RC</a> descreve o resto das mudanças significativas no React 17.</p>
<p>Só tivemos que mudar menos de vinte componentes de mais de 100.000 no código de produto do Facebook para trabalhar com essas mudanças, então <strong>esperamos que a maioria dos aplicativos possa atualizar para React 17 sem muitos problemas</strong>. Por favor <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">nos conte</a> se você tiver problemas.</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>Nova transformação JSX </h2>
<p>React 17 apoia a <a href="/blog/2020/09/22/introducing-the-new-jsx-transform.html">nova transformação JSX</a>. Também fizemos backport para ele para React 16.14.0, React 15.7.0 e 0.14.10. Observe que é totalmente opcional e você não precisa usá-lo. A transformação JSX clássica continuará funcionando e não há planos de deixar de suportá-la.</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>O React Native tem uma programação de lançamento separada. Conseguimos o suporte para React 17 no React Native 0.64. Como sempre, você pode acompanhar as discussões de lançamento nos lançamentos da React Native Community <a href="https://github.com/react-native-community/releases" target="_blank" rel="nofollow noopener noreferrer">rastreador de issues</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>Instalação </h2>
<p>Para instalar React 17 com npm, rode:</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>Para instalar React 17 com Yarn, rode:</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>Também fornecemos compilações UMD do React por meio de um 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>Consulte a documentação para <a href="/docs/installation.html">instruções de instalação detalhadas</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>Adiciona <code class="gatsby-code-text">react/jsx-runtime</code> e <code class="gatsby-code-text">react/jsx-dev-runtime</code> para o <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> em <a href="https://github.com/facebook/react/pull/18299" target="_blank" rel="nofollow noopener noreferrer">#18299</a>)</li>
<li>Crie pilhas de componentes a partir de frames de erro nativos. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">#18561</a>)</li>
<li>Permite especificar <code class="gatsby-code-text">displayName</code> no contexto para pilhas aprimoradas. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18224" target="_blank" rel="nofollow noopener noreferrer">#18224</a>)</li>
<li>Evita <code class="gatsby-code-text">'use strict'</code> de vazamento nos pacotes UMD. (<a href="https://github.com/koba04" target="_blank" rel="nofollow noopener noreferrer">@koba04</a> em <a href="https://github.com/facebook/react/pull/19614" target="_blank" rel="nofollow noopener noreferrer">#19614</a>)</li>
<li>Para de usar <code class="gatsby-code-text">fb.me</code> para redirecionamentos. (<a href="https://github.com/cylim" target="_blank" rel="nofollow noopener noreferrer">@cylim</a> em <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>Delega eventos aos roots em vez de <code class="gatsby-code-text">document</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/18195" target="_blank" rel="nofollow noopener noreferrer">#18195</a> e <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>Limpa todos os efeitos antes de executar os próximos efeitos. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/17947" target="_blank" rel="nofollow noopener noreferrer">#17947</a>)</li>
<li>Roda <code class="gatsby-code-text">useEffect</code> limpando funções assíncronas. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/17925" target="_blank" rel="nofollow noopener noreferrer">#17925</a>)</li>
<li>Usa o navegador <code class="gatsby-code-text">focusin</code> e <code class="gatsby-code-text">focusout</code> para <code class="gatsby-code-text">onFocus</code> e <code class="gatsby-code-text">onBlur</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/19186" target="_blank" rel="nofollow noopener noreferrer">#19186</a>)</li>
<li>Faz com que eventos <code class="gatsby-code-text">Capture</code> usem a fase de captura do navegador. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/19221" target="_blank" rel="nofollow noopener noreferrer">#19221</a>)</li>
<li>Não imita o borbulhar do evento <code class="gatsby-code-text">onScroll</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19464" target="_blank" rel="nofollow noopener noreferrer">#19464</a>)</li>
<li>Lança se o componente <code class="gatsby-code-text">forwardRef</code> ou<code class="gatsby-code-text">memo</code> retornar ʻundefined`. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Remove o pool de eventos. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/18969" target="_blank" rel="nofollow noopener noreferrer">#18969</a>)</li>
<li>Para de expor detalhes internos que não serão necessários para o React Native Web. (<a href="https://github.com/necolas" target="_blank" rel="nofollow noopener noreferrer">@necolas</a> em <a href="https://github.com/facebook/react/pull/18483" target="_blank" rel="nofollow noopener noreferrer">#18483</a>)</li>
<li>Anexa todos os ouvintes de eventos conhecidos quando o hoot for montado. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19659" target="_blank" rel="nofollow noopener noreferrer">#19659</a>)</li>
<li>Desabilita <code class="gatsby-code-text">console</code> na segunda passagem de renderização do modo DEV, renderização dupla. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>Rejeita o não documentado e enganoso API do <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/13407" target="_blank" rel="nofollow noopener noreferrer">#13407</a>)</li>
<li>Renomeia os nomes dos campos privados usados ​​nos internos. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/18377" target="_blank" rel="nofollow noopener noreferrer">#18377</a>)</li>
<li>Não chama a API User Timing no desenvolvimento. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/18417" target="_blank" rel="nofollow noopener noreferrer">#18417</a>)</li>
<li>Desabilita o console durante a renderização repetida no modo estrito. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>No Modo Estrito, os componentes de renderização dupla sem Hooks. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18430" target="_blank" rel="nofollow noopener noreferrer">#18430</a>)</li>
<li>Permite chamadas <code class="gatsby-code-text">ReactDOM.flushSync</code> durante os métodos de ciclo de vida (com aviso). (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18759" target="_blank" rel="nofollow noopener noreferrer">#18759</a>)</li>
<li>Adiciona a propriedade <code class="gatsby-code-text">code</code> aos objetos de evento do teclado. (<a href="https://github.com/bl00mber" target="_blank" rel="nofollow noopener noreferrer">@bl00mber</a> em <a href="https://github.com/facebook/react/pull/18287" target="_blank" rel="nofollow noopener noreferrer">#18287</a>)</li>
<li>Adiciona a propriedade <code class="gatsby-code-text">disableRemotePlayback</code> para elementos <code class="gatsby-code-text">video</code>. (<a href="https://github.com/tombrowndev" target="_blank" rel="nofollow noopener noreferrer">@tombrowndev</a> em <a href="https://github.com/facebook/react/pull/18619" target="_blank" rel="nofollow noopener noreferrer">#18619</a>)</li>
<li>Adiciona a propriedade <code class="gatsby-code-text">enterKeyHint</code> para elementos <code class="gatsby-code-text">input</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18634" target="_blank" rel="nofollow noopener noreferrer">#18634</a>)</li>
<li>Avisa quando <code class="gatsby-code-text">value</code> não é fornecido para <code class="gatsby-code-text">&lt;Context.Provider></code>. (<a href="https://github.com/charlie1404" target="_blank" rel="nofollow noopener noreferrer">@charlie1404</a> em <a href="https://github.com/facebook/react/pull/19054" target="_blank" rel="nofollow noopener noreferrer">#19054</a>)</li>
<li>Avisa quando o componente<code class="gatsby-code-text">memo</code> ou <code class="gatsby-code-text">forwardRef</code> retorna <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Melhora a mensagem de erro para atualizações inválidas. (<a href="https://github.com/JoviDeCroock" target="_blank" rel="nofollow noopener noreferrer">@JoviDeCroock</a> em <a href="https://github.com/facebook/react/pull/18316" target="_blank" rel="nofollow noopener noreferrer">#18316</a>)</li>
<li>Exclui forwardRef e memo dos frames da pilha. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18559" target="_blank" rel="nofollow noopener noreferrer">#18559</a>)</li>
<li>Melhora a mensagem de erro ao alternar entre entradas controladas e não controladas. (<a href="https://github.com/vcarl" target="_blank" rel="nofollow noopener noreferrer">@vcarl</a> em <a href="https://github.com/facebook/react/pull/17070" target="_blank" rel="nofollow noopener noreferrer">#17070</a>)</li>
<li>Mantém <code class="gatsby-code-text">onTouchStart</code>, <code class="gatsby-code-text">onTouchMove</code>, e <code class="gatsby-code-text">onWheel</code> passivo. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19654" target="_blank" rel="nofollow noopener noreferrer">#19654</a>)</li>
<li>Conserta <code class="gatsby-code-text">setState</code> em desenvolvimento dentro de um iframe fechado. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19220" target="_blank" rel="nofollow noopener noreferrer">#19220</a>)</li>
<li>Corrige resgate de renderização para componentes lentos com <code class="gatsby-code-text">defaultProps</code>. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> em <a href="https://github.com/facebook/react/pull/18539" target="_blank" rel="nofollow noopener noreferrer">#18539</a>)</li>
<li>Corrige um aviso de falso positivo quando <code class="gatsby-code-text">dangerouslySetInnerHTML</code> é <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18676" target="_blank" rel="nofollow noopener noreferrer">#18676</a>)</li>
<li>Corrige utilitários de teste fora do padrão de implementação <code class="gatsby-code-text">require</code>. (<a href="https://github.com/just-boris" target="_blank" rel="nofollow noopener noreferrer">@just-boris</a> em <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> relatando um incorreto <code class="gatsby-code-text">event.type</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <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> relatado como <code class="gatsby-code-text">undefined</code> em Firefox. (<a href="https://github.com/claytercek" target="_blank" rel="nofollow noopener noreferrer">@claytercek</a> em <a href="https://github.com/facebook/react/pull/19607" target="_blank" rel="nofollow noopener noreferrer">#19607</a>)</li>
<li>Corrige “erro não especificado” em IE11. (<a href="https://github.com/hemakshis" target="_blank" rel="nofollow noopener noreferrer">@hemakshis</a> em <a href="https://github.com/facebook/react/pull/19664" target="_blank" rel="nofollow noopener noreferrer">#19664</a>)</li>
<li>Corrige a renderização em uma sombra root. (<a href="https://github.com/Jack-Works" target="_blank" rel="nofollow noopener noreferrer">@Jack-Works</a> em <a href="https://github.com/facebook/react/pull/15894" target="_blank" rel="nofollow noopener noreferrer">#15894</a>)</li>
<li>Corrige <code class="gatsby-code-text">movementX/Y</code> polyfill com eventos de captura. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19672" target="_blank" rel="nofollow noopener noreferrer">#19672</a>)</li>
<li>Usa delegação para <code class="gatsby-code-text">onSubmit</code> e <code class="gatsby-code-text">onReset</code> eventos. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19333" target="_blank" rel="nofollow noopener noreferrer">#19333</a>)</li>
<li>Melhora o uso de memória. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <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>Torne o comportamento do <code class="gatsby-code-text">useCallback</code> consistente com ʻuseMemo` para o renderizador do servidor.(<a href="https://github.com/alexmckenley" target="_blank" rel="nofollow noopener noreferrer">@alexmckenley</a> em <a href="https://github.com/facebook/react/pull/18783" target="_blank" rel="nofollow noopener noreferrer">#18783</a>)</li>
<li>Corrige o vazamento de estado quando um componente de função é acionado. (<a href="https://github.com/pmaccart" target="_blank" rel="nofollow noopener noreferrer">@pmaccart</a> em <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>Melhora <code class="gatsby-code-text">findByType</code> mensagem de erro. (<a href="https://github.com/henryqdineen" target="_blank" rel="nofollow noopener noreferrer">@henryqdineen</a> em <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>Modo Simultâneo (Experimental) </h3>
<ul>
<li>Renova as heurísticas de lote de prioridade. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18796" target="_blank" rel="nofollow noopener noreferrer">#18796</a>)</li>
<li>Adiciona o prefixo <code class="gatsby-code-text">unstable_</code> antes do experimental APIs. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <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> e <code class="gatsby-code-text">unstable_flushDiscreteUpdates</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remove o argumento <code class="gatsby-code-text">timeoutMs</code>. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/19703" target="_blank" rel="nofollow noopener noreferrer">#19703</a>)</li>
<li>Desabilita pré-renderização <code class="gatsby-code-text">&lt;div hidden /></code> em favor de uma futura API diferente. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18917" target="_blank" rel="nofollow noopener noreferrer">#18917</a>)</li>
<li>Adiciona <code class="gatsby-code-text">unstable_expectedLoadTime</code> ao Suspense para árvores vinculadas à CPU. (<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>Adiciona um Hook experimental <code class="gatsby-code-text">unstable_useOpaqueIdentifier</code>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> em <a href="https://github.com/facebook/react/pull/17322" target="_blank" rel="nofollow noopener noreferrer">#17322</a>)</li>
<li>Adiciona uma API experimental <code class="gatsby-code-text">unstable_startTransition</code>. (<a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a> em <a href="https://github.com/facebook/react/pull/19696" target="_blank" rel="nofollow noopener noreferrer">#19696</a>)</li>
<li>Usando <code class="gatsby-code-text">act</code> no renderizador de teste não libera mais fallbacks do Suspense. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18596" target="_blank" rel="nofollow noopener noreferrer">#18596</a>)</li>
<li>Usa o tempo limite de renderização global para CPU Suspense. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/19643" target="_blank" rel="nofollow noopener noreferrer">#19643</a>)</li>
<li>Limpa o conteúdo hoot existente antes da montagem. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/18730" target="_blank" rel="nofollow noopener noreferrer">#18730</a>)</li>
<li>Corrige um bug com limites de erro. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18265" target="_blank" rel="nofollow noopener noreferrer">#18265</a>)</li>
<li>Corrige um bug que causava atualizações perdidas em uma árvore suspensa. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18384" target="_blank" rel="nofollow noopener noreferrer">#18384</a> e <a href="https://github.com/facebook/react/pull/18457" target="_blank" rel="nofollow noopener noreferrer">#18457</a>)</li>
<li>Corrige um bug que causava atualizações da fase de renderização perdidas (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18537" target="_blank" rel="nofollow noopener noreferrer">#18537</a>)</li>
<li>Corrige um bug em SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18412" target="_blank" rel="nofollow noopener noreferrer">#18412</a>)</li>
<li>Corrige um bug que fazia com que o substituto do Suspense fosse exibido muito cedo. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18411" target="_blank" rel="nofollow noopener noreferrer">#18411</a>)</li>
<li>Corrige um bug com componentes de classe dentro de SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18448" target="_blank" rel="nofollow noopener noreferrer">#18448</a>)</li>
<li>Corrige um bug com inputs que pode fazer com que as atualizações sejam descartadas. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> em <a href="https://github.com/facebook/react/pull/18515" target="_blank" rel="nofollow noopener noreferrer">#18515</a> e <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18535" target="_blank" rel="nofollow noopener noreferrer">#18535</a>)</li>
<li>Corrige um bug que fazia com que o recurso de suspensão do Suspense travasse.  (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18663" target="_blank" rel="nofollow noopener noreferrer">#18663</a>)</li>
<li>Não corta a tail de uma SuspenseList se carregando informações. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18854" target="_blank" rel="nofollow noopener noreferrer">#18854</a>)</li>
<li>Conserta um bug em <code class="gatsby-code-text">useMutableSource</code> isso pode acontecer quando alterações<code class="gatsby-code-text">getSnapshot</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/18297" target="_blank" rel="nofollow noopener noreferrer">#18297</a>)</li>
<li>Corrige um sério bug em <code class="gatsby-code-text">useMutableSource</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/18912" target="_blank" rel="nofollow noopener noreferrer">#18912</a>)</li>
<li>Avisa se chamando setState fora da renderização, mas antes do commit. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18838" target="_blank" rel="nofollow noopener noreferrer">#18838</a>)</li>
</ul>]]></description><link>https://pt-br.reactjs.org/blog/2020/10/20/react-v17.html</link><guid isPermaLink="false">https://pt-br.reactjs.org/blog/2020/10/20/react-v17.html</guid><pubDate>Tue, 20 Oct 2020 00:00:00 GMT</pubDate></item><item><title><![CDATA[Apresentando o novo JSX Transform]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://pt-br.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Embora o React 17 <a href="/blog/2020/08/10/react-v17-rc.html">não contenha novos recursos</a>, ele fornecerá suporte para uma nova versão do JSX Transform. Neste post, descreveremos o que é e como experimentá-lo.</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>O Que é um JSX Transform? </h2>
<p>Os navegadores não entendem JSX imediatamente, então a maioria dos usuários do React confia em um compilador como o Babel ou TypeScript para <strong>transformar o código JSX em JavaScript regular</strong>. Muitos toolkits pré-configurados como o Create React App ou Next.js também incluem um JSX Transform por baixo do capô.</p>
<p>Junto com a versão React 17, queríamos fazer algumas melhorias no JSX Transform, mas não queríamos quebrar as configurações existentes. É por isso que <a href="https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154httpsgithubcombabelbabelpull11154" target="_blank" rel="nofollow noopener noreferrer">trabalhamos com Babel</a> para <strong>oferecer uma versão nova e reescrita do JSX Transform</strong> para pessoas que gostariam de atualizar.</p>
<p>Atualizar para a nova transformação é totalmente opcional, mas tem alguns benefícios:</p>
<ul>
<li>Com a nova transformação, você pode <strong>usar JSX sem importar o React</strong>.</li>
<li>Dependendo de sua configuração, a saída compilada pode <strong>melhorar ligeiramente o tamanho do pacote</strong>.</li>
<li>Isso permitirá melhorias futuras que <strong>reduzem o número de conceitos</strong> que você precisa para aprender React.</li>
</ul>
<p><strong>Esta atualização não mudará a sintaxe JSX e não é necessária.</strong> O antigo JSX Transform continuará funcionando normalmente e não há planos de remover o suporte para ele.</p>
<p><a href="/blog/2020/08/10/react-v17-rc.html">React 17 RC</a> já inclui suporte para a nova transformação, então experimente! Para facilitar a adoção <strong>também adaptamos seu suporte</strong> para React 16.14.0, React 15.7.0 e React 0.14.10. Você pode encontrar as instruções de atualização para diferentes ferramentas <a href="#how-to-upgrade-to-the-new-jsx-transform">abaixo</a>.</p>
<p>Agora, vamos examinar mais de perto as diferenças entre a velha e a nova transformação.</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>O Que Há de Diferente na Nova Transformação? </h2>
<p>Quando você usa JSX, o compilador o transforma em chamadas de função React que o navegador pode entender. <strong>A antiga transformação JSX</strong> transforma JSX em chamadas <code class="gatsby-code-text">React.createElement(...)</code>.</p>
<p>Por exemplo, digamos que seu código-fonte tenha a seguinte aparência:</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>Nos bastidores, a antiga transformação JSX o transforma em JavaScript regular:</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>Nota</p>
<p><strong>Seu código-font não precisa ser alterado de forma alguma.</strong> Estamos descrevendo como a transformação JSX transforma seu código-fonte JSX no código JavaScript que um navegador pode entender.</p>
</blockquote>
<p>No entanto, isso não é perfeito:</p>
<ul>
<li>Como JSX foi compilado em <code class="gatsby-code-text">React.createElement</code>, <code class="gatsby-code-text">React</code> precisa estar no escopo se você usasse JSX.</li>
<li>Existe algumas <a href="https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#motivation" target="_blank" rel="nofollow noopener noreferrer">melhorias e simplificações de desempenho</a> que <code class="gatsby-code-text">React.createElement</code> não permite.</li>
</ul>
<p>Para resolver esses problemas, o React 17 apresenta dois novos pontos de entrada para o pacote React que devem ser usados apenas por compiladores como Babel e TypeScript. Em vez de transformar JSX em <code class="gatsby-code-text">React.createElement</code>, <strong>a nova transformação JSX</strong> importa automaticamente funções especiais desses novos pontos de entrada no pacote React e os chama.</p>
<p>Digamos que seu código-fonte tenha a seguinte aparência:</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>É para isso que a nova transformação JSX o compila:</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Inserido por um compilador (não importe você mesmo!)</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>Observe como nosso código original <strong>não precisava mais importar o React</strong> para usar JSX! (Mas ainda precisaríamos importar o React para usar Hooks ou outras exportações que o React fornece.)</p>
<p><strong>Esta mudança é totalmente compatível com todo o código JSX existente</strong>, assim você não terá que mudar seus componentes. Se estiver curioso, você pode verificar a <a href="https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#detailed-design" target="_blank" rel="nofollow noopener noreferrer">RFC técnica</a> para obter mais detalhes sobre como a nova transformação funciona.</p>
<blockquote>
<p>Nota</p>
<p>As funções dentro de <code class="gatsby-code-text">react/jsx-runtime</code> e <code class="gatsby-code-text">react/jsx-dev-runtime</code> devem ser usadas apenas pela transformação do compilador. Se você precisa criar elementos manualmente em seu código, você deve continuar usando <code class="gatsby-code-text">React.createElement</code>. Ele continuará a funcionar e não irá embora.</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>Como Fazer Upgrade para a Nova Transformação JSX </h2>
<p>Se você não estiver pronto para atualizar para a nova transformação JSX ou se estiver usando JSX para outra biblioteca, não se preocupe. A transformação antiga não será removida e continuará a ter suporte.</p>
<p>Se quiser fazer upgrade, você precisará de duas coisas:</p>
<ul>
<li><strong>Uma versão do React que suporta a nova transformação</strong> (<a href="/blog/2020/08/10/react-v17-rc.html">React 17 RC</a> e superior suportam, mas também lançamos React 16.14.0, React 15.7.0 e React 0.14.10 para pessoas que ainda estão nas versões principais mais antigas).</li>
<li><strong>Um compilador compatível</strong> (consulte as instruções para diferentes ferramentas abaixo).</li>
</ul>
<p>Como a nova transformação JSX não exige que o React esteja no escopo, <a href="#removing-unused-react-imports">também preparamos um script automatizado</a> que removerá as importações desnecessárias de sua base de código.</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>+ usa a nova transformação para versões compatíveis do React.</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>+ usa a nova transformação para versões compatíveis do React.</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>+ usa a nova transformação para versões compatíveis do React.</p>
<blockquote>
<p>Nota</p>
<p>Se você obtiver <a href="https://github.com/gatsbyjs/gatsby/issues/26979" target="_blank" rel="nofollow noopener noreferrer">este erro de Gatsby</a> após atualizar para React 17 RC, execute <code class="gatsby-code-text">npm update</code> para corrigi-lo.</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>Configuração Manual do Babel </h3>
<p>O suporte para a nova transformação JSX está disponível no Babel <a href="https://babeljs.io/blog/2020/03/16/7.9.0" target="_blank" rel="nofollow noopener noreferrer">v7.9.0</a> e superior.</p>
<p>Primeiro, você precisará atualizar para a última transformação do Babel e do plugin.</p>
<p>Se você estiver usando <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"># para usuários npm</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"># para usuários yarn</span>
<span class="token function">yarn</span> upgrade @babel/core @babel/plugin-transform-react-jsx</code></pre></div>
<p>Se você estiver usando <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"># para usuários npm</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"># para usuários yarn</span>
<span class="token function">yarn</span> upgrade @babel/core @babel/preset-react</code></pre></div>
<p>Atualmente, a antiga transformação <code class="gatsby-code-text">{"runtime": "classic"}</code> é a opção padrão. Para habilitar a nova transformação, você pode passar <code class="gatsby-code-text">{"runtime": "automatic"}</code> como uma opção para <code class="gatsby-code-text">@babel/plugin-transform-react-jsx</code> ou <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">// Se você estiver usando @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">// Se você estiver usando @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>A partir do Babel 8, <code class="gatsby-code-text">"automatic"</code> será o tempo de execução padrão para ambos os plug-ins. Para obter mais informações, verifique a documentação do Babel para <a href="https://babeljs.io/docs/en/babel-plugin-transform-react-jsx" target="_blank" rel="nofollow noopener noreferrer">@babel/plugin-transform-react-jsx</a> e <a href="https://babeljs.io/docs/en/babel-preset-react" target="_blank" rel="nofollow noopener noreferrer">@babel/preset-react</a>.</p>
<blockquote>
<p>Nota</p>
<p>Se você usar JSX com uma biblioteca diferente de React, você pode usar <a href="https://babeljs.io/docs/en/babel-preset-react#importsource" target="_blank" rel="nofollow noopener noreferrer">a opção <code class="gatsby-code-text">importSource</code></a> para importar dessa biblioteca - desde que forneça os pontos de entrada necessários. Como alternativa, você pode continuar usando a transformação clássica, que continuará a ser compatível.</p>
<p>Se você é um autor de biblioteca e está implementando o ponto de entrada <code class="gatsby-code-text">/jsx-runtime</code> para sua biblioteca, tenha em mente que <a href="https://github.com/facebook/react/issues/20031#issuecomment-710346866" target="_blank" rel="nofollow noopener noreferrer">há um caso</a> em que até mesmo a nova transformação tem que voltar para <code class="gatsby-code-text">createElement</code> para compatibilidade de versões anteriores. Nesse caso, ele irá importar automaticamente <code class="gatsby-code-text">createElement</code> diretamente do ponto de entrada <em>root</em> especificado por <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>Se você estiver usando <a href="https://github.com/yannickcr/eslint-plugin-react" target="_blank" rel="nofollow noopener noreferrer">eslint-plugin-react</a>, as regras de <code class="gatsby-code-text">react/jsx-uses-react</code> e <code class="gatsby-code-text">react/react-in-jsx-scope</code> não são mais necessárias e podem ser desativadas ou removidas.</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 suporta a nova transformação JSX em <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#jsx-factories" target="_blank" rel="nofollow noopener noreferrer">v4.1</a>.</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 suporta a nova transformação JSX em <a href="https://github.com/facebook/flow/releases/tag/v0.126.0" target="_blank" rel="nofollow noopener noreferrer">v0.126.0</a> para cima, adicionando <code class="gatsby-code-text">react.runtime = automatic</code> às opções de configuração do Flow.</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>Removendo Imports React não Utilizadas </h2>
<p>Como a nova transformação JSX importará automaticamente as funções <code class="gatsby-code-text">react/jsx-runtime</code> necessárias, o React não precisará mais estar no escopo quando você usar JSX. Isso pode levar a importação React não utilizadas em seu código. Não faz mal mantê-los, mas se quiser removê-los, recomendamos a execução de um script <a href="https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb" target="_blank" rel="nofollow noopener noreferrer">“codemod”</a> para removê-los automaticamente:</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>Nota</p>
<p>Se você estiver recebendo errors ao executar o codemod, tente especificar um dialeto JavaScript diferente quando <code class="gatsby-code-text">npx react-codemod update-react-imports</code> solicitar que você escolha um. Em particular, neste momento, a configuração “JavaScript com Flow” suporta sintaxe mais recente do que a configuração “JavaScript”, mesmo se você não usar o Flow. <a href="https://github.com/reactjs/react-codemod/issues" target="_blank" rel="nofollow noopener noreferrer">Crie uma issue</a> se você tiver problemas.</p>
<p>Lembre-se de que a saída do codemod nem sempre corresponderá ao estilo de codificação do seu projeto, então você pode querer executar <a href="https://prettier.io/" target="_blank" rel="nofollow noopener noreferrer">Prettier</a> depois que o codemod terminar para uma formatação consistente.</p>
</blockquote>
<p>Executar este codemod irá:</p>
<ul>
<li>Remover todas as importações React não utilizadas como resultado da atualização para a nova transformação JSX.</li>
<li>Alterar todas as importações React padrão (ou seja, <code class="gatsby-code-text">import React from "react"</code>) para importações nomeadas desestruturadas (ex. <code class="gatsby-code-text">import { useState } from "react"</code>), que é o estilo preferido no futuro. Este codemod <strong>não</strong> afetará as importações de namespace existentes (ou seja, <code class="gatsby-code-text">import * as React from "react"</code>), que também é um estilo válido. As importações padrão continuarão funcionando no React 17, mas, a longo prazo, encorajamos nos afastar delas.</li>
</ul>
<p>Por exemplo,</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">Olá Mundo</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>será substituído por</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">Olá Mundo</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>Se você usar alguma outra importação do React - por exemplo, um Hook - então o codemod irá convertê-lo em uma importação nomeada.</p>
<p>Por exemplo,</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">'Olá Mundo'</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>será substituído por</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">'Olá Mundo'</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>Além de limpar as importações não utilizadas, isso também o ajudará a se preparar para uma versão principal futura do React (não do React 17), que oferecerá suporte aos Módulos ES e não terá uma exportação padrão.</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>Obrigado </h2>
<p>Gostaríamos de agradecer aos mantenedores de Babel, TypeScript, Create React App, Next.js, Gatsby, ESLint e Flow por sua ajuda na implementação e integração da nova transformação JSX. Também queremos agradecer à comunidade React por seus comentários e discussões sobre a <a href="https://github.com/reactjs/rfcs/pull/107" target="_blank" rel="nofollow noopener noreferrer">RFC técnica</a>.</p>]]></description><link>https://pt-br.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html</link><guid isPermaLink="false">https://pt-br.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 Candidato à lançamento: Sem novas funcionalidades]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>This blog site has been archived. Go to <a href="https://pt-br.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Hoje, estamos publicando o primeiro candidato à lançamento do React 17. Já se passaram dois anos e meio desde <a href="/blog/2017/09/26/react-v16.0.html">o principal lançamento anterior do React</a>, que é muito tempo, mesmo para os nossos padrões! Nesta postagem do blog, descreveremos a função desta versão principal, quais mudanças você pode esperar dela e como você pode experimentar esta versão.</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>Sem novas funcionalidades </h2>
<p>A versão React 17 é incomum porque não adiciona nenhum novo recurso voltado para o desenvolvedor. Em vez disso, esta versão está focada principalmente em <strong>tornar mais fácil atualizar o próprio React</strong>.</p>
<p>Estamos trabalhando ativamente nos novos recursos do React, mas eles não fazem parte desta versão. O lançamento do React 17 é uma parte fundamental de nossa estratégia para implementá-los sem deixar ninguém para trás.</p>
<p>Em particular, o <strong>React 17 é uma versão “passo a passo”</strong> que torna mais seguro incorporar uma árvore gerenciada por uma versão do React dentro de uma árvore gerenciada por uma versão diferente do React.</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>Atualizações Graduais </h2>
<p>Nos últimos sete anos, as atualizações do React têm sido “tudo ou nada”. Ou você permanece com uma versão antiga ou atualiza todo o seu aplicativo para uma nova versão. Não havia meio-termo.</p>
<p>Isso funcionou até agora, mas estamos atingindo os limites da estratégia de atualização “tudo ou nada”. Algumas mudanças de API, por exemplo, descontinuar a <a href="/docs/legacy-context.html">legada API de contexto</a>, são impossíveis de fazer de forma automatizada. Mesmo que a maioria dos aplicativos escritos hoje nunca os use, ainda oferecemos suporte para eles no React. Temos que escolher entre suportá-los no React indefinidamente ou deixar alguns aplicativos para trás em uma versão antiga do React. Ambas as opções não são boas.</p>
<p>Portanto, queríamos oferecer outra opção.</p>
<p><strong>React 17 permite atualizações graduais do React.</strong> Quando você atualiza do React 15 para o 16 (ou, em breve, do React 16 para o 17), normalmente atualiza todo o seu aplicativo de uma vez. Isso funciona bem para muitos aplicativos. Mas pode ser cada vez mais desafiador se a base de código foi escrita há mais de alguns anos e não é mantida ativamente. E embora seja possível usar duas versões do React na mesma página, até o React 17 isso era frágil e causava problemas com eventos.</p>
<p>Estamos corrigindo muitos desses problemas com o React 17. Isso significa que <strong>quando o React 18 e as próximas versões futuras forem lançadas, você terá mais opções</strong>. A primeira opção será atualizar todo o seu aplicativo de uma vez, como você pode ter feito antes. Mas você também terá a opção de atualizar seu aplicativo peça por peça. Por exemplo, você pode decidir migrar a maior parte do seu aplicativo para o React 18, mas manter algumas caixas de diálogo <em>lazy-loaded</em> ou um sub-rota no React 17.</p>
<p>Isso não significa que você <em>precise</em> fazer atualizações graduais. Para a maioria dos aplicativos, atualizar tudo de uma vez ainda é a melhor solução. Carregar duas versões do React — mesmo se uma delas for carregada lentamente sob demanda — ainda não é o ideal. No entanto, para aplicativos maiores que não são mantidos ativamente, pode fazer sentido considerar essa opção, e o React 17 permite que esses aplicativos não sejam deixados para trás.</p>
<p>Para permitir atualizações graduais, precisamos fazer algumas mudanças no sistema de eventos do React. O React 17 é um grande lançamento porque essas alterações são potencialmente prejudiciais. Na prática, só tivemos que mudar menos de vinte componentes de mais de 100.000, então <strong>esperamos que a maioria dos aplicativos possa atualizar para o React 17 sem muitos problemas</strong>. <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">Conte-nos</a> se você tiver problemas.</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>Demonstração das atualizações graduais </h3>
<p>Preparamos um <a href="https://github.com/reactjs/react-gradual-upgrade-demo/" target="_blank" rel="nofollow noopener noreferrer">repositório de exemplo</a> demonstrando como carregar lentamente uma versão mais antiga do React, se necessário. Esta demonstração usa Create React App, mas deve ser possível seguir uma abordagem semelhante com qualquer outra ferramenta. Aceitamos pull requests com demonstrações usando outras ferramentas.</p>
<blockquote>
<p>Nota</p>
<p><strong>Adiamos outras mudanças</strong> até depois do React 17. O objetivo desta versão é permitir atualizações graduais. Se atualizar para React 17 fosse muito difícil, isso iria contra o seu propósito.</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>Alterações na delegação de eventos </h2>
<p>Tecnicamente, sempre foi possível aninhar aplicativos desenvolvidos com diferentes versões do React. No entanto, era bastante frágil por causa de como o sistema de eventos React funcionava.</p>
<p>Nos componentes React, você geralmente escreve manipuladores de eventos (event handler) inline:</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>O DOM vanilla equivalente a este código é semelhante à:</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>No entanto, para a maioria dos eventos, o React não os anexa aos nós DOM nos quais você os declara. Em vez disso, o React anexa um manipulador por tipo de evento diretamente no nó <code class="gatsby-code-text">document</code>. Isso é chamado de <a href="https://davidwalsh.name/event-delegate" target="_blank" rel="nofollow noopener noreferrer">delegação de evento</a>. Além de seus benefícios de desempenho em grandes árvores de aplicativos, também torna mais fácil adicionar novos recursos como <a href="https://twitter.com/dan_abramov/status/1200118229697486849" target="_blank" rel="nofollow noopener noreferrer">eventos de repetição</a>.</p>
<p>O React faz a delegação de eventos automaticamente desde seu primeiro lançamento. Quando um evento DOM é disparado no documento, o React descobre qual componente deve ser chamado e, em seguida, o evento React “propaga” para cima através de seus componentes. Mas, nos bastidores, o evento nativo já atingiu o nível <code class="gatsby-code-text">documento</code>, onde o React instala seus manipuladores de eventos.</p>
<p>No entanto, esse é um problema para atualizações graduais.</p>
<p>Se você tiver várias versões do React na página, todas elas registram manipulador de eventos (event handler) na parte superior. Isso quebra <code class="gatsby-code-text">e.stopPropagation()</code>: se uma árvore aninhada parou a propagação de um evento, a árvore externa ainda o receberia. Isso tornou difícil aninhar diferentes versões do React. Essa preocupação não é hipotética — por exemplo, o editor Atom <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">encontrou isso</a> quatro anos atrás.</p>
<p>É por isso que estamos mudando a forma como o React anexa eventos ao DOM nos bastidores.</p>
<p><strong>No React 17, o React não anexará mais manipuladores de eventos no nível do <code class="gatsby-code-text">documento</code>. Em vez disso, ele os anexará ao contêiner DOM raiz no qual sua árvore do React é renderizada:</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>No React 16 e anteriores, o React faria <code class="gatsby-code-text">document.addEventListener()</code> para a maioria dos eventos. O React 17 chamará <code class="gatsby-code-text">rootNode.addEventListener()</code> por debaixo dos panos.</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="Um diagrama mostrando como o React 17 anexa eventos às raízes em vez de anexar ao documento"
        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>Graças a essa mudança, <strong>agora é mais seguro incorporar uma árvore do React gerenciada por uma versão dentro de uma árvore gerenciada por uma versão diferente do React</strong>. Observe que para que isso funcione, ambas as versões precisam ser 17 ou superior, por isso atualizar para React 17 é importante. De certa forma, o React 17 é um lançamento “trampolim” que torna as próximas atualizações graduais viáveis.</p>
<p>Essa mudança também <strong>torna mais fácil incorporar o React em aplicativos desenvolvidos com outras tecnologias</strong>. Por exemplo, se o “shell” externo de seu aplicativo for escrito em jQuery, mas o código mais recente dentro dele for escrito com React, <code class="gatsby-code-text">e.stopPropagation()</code> dentro do código React agora evitará que ele alcance o código jQuery — como você esperaria. Isso também funciona na outra direção. Se você não gosta mais de React e deseja reescrever seu aplicativo — por exemplo, em jQuery — você pode começar a converter o shell externo de React para jQuery sem interromper a propagação do evento.</p>
<p>Confirmamos que <a href="https://github.com/facebook/react/issues/7094" target="_blank" rel="nofollow noopener noreferrer">vários</a> <a href="https://github.com/facebook/react/issues/8693" target="_blank" rel="nofollow noopener noreferrer">problemas</a> <a href="https://github.com/facebook/react/issues/12518" target="_blank" rel="nofollow noopener noreferrer">relatados</a> <a href="https://github.com/facebook/react/issues/13451" target="_blank" rel="nofollow noopener noreferrer">ao longo</a> <a href="https://github.com/facebook/react/issues/4335" target="_blank" rel="nofollow noopener noreferrer">dos</a> <a href="https://github.com/facebook/react/issues/1691" target="_blank" rel="nofollow noopener noreferrer">anos</a> <a href="https://github.com/facebook/react/issues/285#issuecomment-253502585" target="_blank" rel="nofollow noopener noreferrer">em</a> <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">nosso</a> <a href="https://github.com/facebook/react/issues/11530" target="_blank" rel="nofollow noopener noreferrer">rastreador</a> <a href="https://github.com/facebook/react/issues/7128" target="_blank" rel="nofollow noopener noreferrer">de problemas</a> relacionadas à integração do React com o código não React foram corrigidas pelo novo comportamento.</p>
<blockquote>
<p>Nota</p>
<p>Você deve estar se perguntando se isso quebra o <a href="/docs/portals.html">Portals</a> fora do contêiner raiz. A resposta é que o React <em>também</em> ouve eventos nos contêineres do portal, portanto, isso não é um problema.</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>Corrigindo potenciais problemas </h4>
<p>Como acontece com qualquer alteração importante, é provável que algum código precise ser ajustado. No Facebook, tivemos que ajustar cerca de 10 módulos no total (de muitos milhares) para trabalhar com essa mudança.</p>
<p>Por exemplo, se você adicionar manualmente os DOM listners com <code class="gatsby-code-text">document.addEventListener(...)</code>, você pode esperar que eles capturem todos os eventos React. No React 16 e anteriores, mesmo se você chamar <code class="gatsby-code-text">e.stopPropagation()</code> em um manipulador de eventos (event handler) do React, seus listners <code class="gatsby-code-text">document</code> personalizados ainda os receberão porque o evento nativo <em>já</em> está no nível do documento. Com React 17, a propagação <em>iria</em> parar (conforme solicitado!), Então seus manipuladores de <code class="gatsby-code-text">document</code> não disparariam:</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">// Este manipulador personalizado não receberá mais cliques</span>
  <span class="token comment">// dos componentes React que chamaram e.stopPropagation()</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>Você pode corrigir um código como esse convertendo seu listener para usar a <a href="https://javascript.info/bubbling-and-capturing#capturing" target="_blank" rel="nofollow noopener noreferrer">fase de captura</a>. Para fazer isso, você pode passar <code class="gatsby-code-text">{ capture: true }</code> como o terceiro argumento para <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">// Agora este event handlers usa a fase de captura</span>
  <span class="token comment">// então ele recebe *todas* os eventos de clique abaixo!</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>Observe como essa estratégia é mais resiliente no geral — por exemplo, ela provavelmente corrigirá bugs existentes em seu código que acontecem quando <code class="gatsby-code-text">e.stopPropagation()</code> é chamado fora de um manipulador de eventos (event handler) React. Em outras palavras, a <strong>propagação do evento no React 17 funciona mais próxima do DOM regular</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>Outras alterações significativas </h2>
<p>Mantivemos as alterações significativas no React 17 ao mínimo. Por exemplo, ele não remove nenhum dos métodos que foram descontinuados nas versões anteriores. No entanto, inclui algumas outras alterações importantes que têm sido relativamente seguras em nossa experiência. No total, tivemos que ajustar menos de 20 de mais de 100.000 nossos componentes por causa deles.</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>Alinhando com navegadores </h3>
<p>Fizemos algumas alterações menores relacionadas ao sistema de eventos:</p>
<ul>
<li>O evento <code class="gatsby-code-text">onScroll</code> <strong>não propaga mais</strong> a fim de previnir algumas <a href="https://github.com/facebook/react/issues/15723" target="_blank" rel="nofollow noopener noreferrer">confusões comuns</a>.</li>
<li>Os eventos React <code class="gatsby-code-text">onFocus</code> e <code class="gatsby-code-text">onBlur</code> passaram a usar os eventos nativos <code class="gatsby-code-text">focusin</code> e<code class="gatsby-code-text">focusout</code> por debaixo dos panos, que se aproximam mais do comportamento existente do React e às vezes fornecem informações extras.</li>
<li>Os eventos de fase de captura (por exemplo, <code class="gatsby-code-text">onClickCapture</code>) agora usam ouvintes de fase de captura do navegador real.</li>
</ul>
<p>Essas mudanças alinham o React mais de perto com o comportamento do navegador e melhoram a interoperabilidade.</p>
<blockquote>
<p>Nota</p>
<p>Embora o React 17 tenha mudado de <code class="gatsby-code-text">focus</code> para<code class="gatsby-code-text">focusin</code> <em>por debaixo dos panos</em> para o evento <code class="gatsby-code-text">onFocus</code>, note que isso <strong>não</strong> afetou o comportamento de propagação. No React, o evento <code class="gatsby-code-text">onFocus</code> sempre propagava e continua a ocorrer no React 17 porque geralmente é um padrão mais útil. Consulte <a href="https://codesandbox.io/s/strange-albattani-7tqr7?file=/src/App.js" target="_blank" rel="nofollow noopener noreferrer">este sandbox</a> para as diferentes verificações que você pode adicionar para diferentes casos de uso específicos.</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>Sem pool de eventos </h3>
<p>O React 17 remove a otimização de pooling de eventos do React. Ele não melhora o desempenho em navegadores modernos e confunde até mesmo usuários experientes do 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">// Isso trava no React 16 e anteriores:</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>Isso ocorre porque o React reutilizou os objetos de evento entre diferentes eventos para desempenho em navegadores antigos e definiu todos os campos de evento como <code class="gatsby-code-text">null</code> entre eles. Com o React 16 e anteriores, você deve chamar <code class="gatsby-code-text">e.persist()</code> para usar o evento apropriadamente ou ler a propriedade que você precisa anteriormente.</p>
<p><strong>No React 17, este código funciona conforme o esperado. A antiga otimização do pool de eventos foi totalmente removida, para que você possa ler os campos do evento sempre que precisar.</strong></p>
<p>Esta é uma mudança de comportamento, e é por isso que a estamos marcando como falha, mas na prática não vimos nada quebrar no Facebook. (Talvez até tenha corrigido alguns bugs!) Observe que <code class="gatsby-code-text">e.persist()</code> ainda está disponível no objeto de evento React, mas agora não faz nada.</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>Tempo de limpeza do Effect </h3>
<p>Estamos tornando o tempo da função de limpeza <code class="gatsby-code-text">useEffect</code> mais consistente.</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">// Este é o próprio Effect.</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">// Esta é sua limpeza.</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>A maioria dos efeitos não precisa atrasar as atualizações da tela, portanto, o React os executa de forma assíncrona logo após a atualização ser refletida na tela. (Para os raros casos em que você precisa de um efeito para bloquear a pintura, por exemplo, para medir e posicionar uma tooltip, prefira <code class="gatsby-code-text">useLayoutEffect</code>.)</p>
<p>No entanto, quando um componente é desmontado, as funções de <em>limpeza</em> de efeito usadas para serem executadas de maneira síncrona (semelhante a <code class="gatsby-code-text">componentWillUnmount</code> sendo síncrono em classes). Descobrimos que isso não é ideal para aplicativos maiores porque retarda as transições de telas grandes (por exemplo, alternar entre guias).</p>
<p><strong>No React 17, a função de limpeza de efeito sempre é executada de forma assíncrona — por exemplo, se o componente está desmontado, a limpeza é executada <em>após</em> a tela ter sido atualizada.</strong></p>
<p>Isso reflete como os próprios efeitos funcionam mais de perto. Nos raros casos em que você pode querer confiar na execução síncrona, você pode alternar para <code class="gatsby-code-text">useLayoutEffect</code>.</p>
<blockquote>
<p>Nota</p>
<p>Você deve estar se perguntando se isso significa que agora você não conseguirá corrigir avisos sobre <code class="gatsby-code-text">setState</code> em componentes não montados. Não se preocupe — o React verifica especificamente este caso e <em>não</em> dispara avisos de <code class="gatsby-code-text">setState</code> no curto espaço entre a desmontagem e a limpeza.<strong>Portanto, as solicitações ou intervalos de cancelamento de código quase sempre podem permanecer os mesmos.</strong></p>
</blockquote>
<p>Além disso, o React 17 sempre executará todas as funções de limpeza de efeitos (para todos os componentes) antes de executar quaisquer novos efeitos. O React 16 só garantiu essa ordem para efeitos dentro de um componente.</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>Problemas potenciais </h4>
<p>Nós vimos apenas alguns componentes quebrarem com essa mudança, embora as bibliotecas reutilizáveis ​​possam precisar testá-lo mais completamente. Um exemplo de código problemático pode ser assim:</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>O problema é que <code class="gatsby-code-text">someRef.current</code> é mutável, portanto, no momento em que a função de limpeza é executada, pode ter sido definido como <code class="gatsby-code-text">null</code>. A solução é capturar quaisquer valores mutáveis ​​<em>dentro</em> do efeito:</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>Não esperamos que este seja um problema comum porque <a href="https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks" target="_blank" rel="nofollow noopener noreferrer">nossa regra de lint <code class="gatsby-code-text">eslint-plugin-react-hooks /haustive-deps</code></a> (certifique-se de usá-lo!) sempre alertamos sobre isso.</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>Erros consistentes para retornar indefinido </h3>
<p>No React 16 e anteriores, retornar <code class="gatsby-code-text">undefined</code> sempre foi um erro:</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">// Erro: nada foi retornado da renderização</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Isso ocorre em parte porque é fácil retornar <code class="gatsby-code-text">undefined</code> involuntariamente:</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">// Esquecemos de escrever return, então este componente retorna indefinido.</span>
  <span class="token comment">// React mostra isso como um erro em vez de ignorá-lo.</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>Anteriormente, o React fazia isso apenas para componentes de classe e função, mas não verificava os valores de retorno dos componentes <code class="gatsby-code-text">forwardRef</code> e <code class="gatsby-code-text">memo</code>. Isso ocorreu devido a um erro de codificação.</p>
<p><strong>No React 17, o comportamento dos componentes <code class="gatsby-code-text">forwardRef</code> e <code class="gatsby-code-text">memo</code> é consistente com funções regulares e componentes de classe. Retornar <code class="gatsby-code-text">undefined</code> deles é um erro.</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">// Esquecemos de escrever return, então este componente retorna indefinido.</span>
  <span class="token comment">// React 17 mostra isso como um erro em vez de ignorá-lo.</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">// Esquecemos de escrever return, então este componente retorna indefinido.</span>
  <span class="token comment">// React 17 mostra isso como um erro em vez de ignorá-lo.</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>Para os casos em que você não deseja renderizar nada intencionalmente, retorne <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>Pilhas de componentes nativos </h3>
<p>Quando você lança um erro no navegador, o navegador fornece um rastreamento de pilha com nomes de função JavaScript e seus locais. No entanto, as pilhas de JavaScript geralmente não são suficientes para diagnosticar um problema porque a hierarquia da árvore React pode ser tão importante. Você quer saber não apenas que um <code class="gatsby-code-text">Button</code> gerou um erro, mas <em>onde na árvore React</em> esse <code class="gatsby-code-text">Button</code> está.</p>
<p>Para resolver isso, o React 16 começou a imprimir “pilhas de componentes” quando você tinha um erro. Ainda assim, eles costumavam ser inferiores às pilhas nativas de JavaScript. Em particular, eles não podiam ser clicados no console porque o React não sabia onde a função foi declarada no código-fonte. Além disso, eles eram <a href="https://github.com/facebook/react/issues/12757" target="_blank" rel="nofollow noopener noreferrer">praticamente inúteis na produção</a>. Ao contrário das pilhas JavaScript reduzidas regulares, que podem ser restauradas automaticamente aos nomes das funções originais com um mapa de origem, com as pilhas de componentes React você tinha que escolher entre as pilhas de produção e o tamanho do pacote.</p>
<p><strong>No React 17, as pilhas de componentes são geradas usando um mecanismo diferente que as une a partir das pilhas JavaScript nativas regulares. Isso permite que você obtenha os rastreamentos de pilha do componente React totalmente simbolizados em um ambiente de produção.</strong></p>
<p>A maneira como o React implementa isso é um tanto heterodoxa. Atualmente, os navegadores não fornecem uma maneira de obter o quadro de pilha de uma função (arquivo de origem e localização). Portanto, quando o React detecta um erro, ele agora <em>reconstrói</em> sua pilha de componentes lançando (e capturando) um erro temporário de dentro de cada um dos componentes acima, quando possível. Isso adiciona uma pequena penalidade de desempenho para travamentos, mas só acontece uma vez por tipo de componente.</p>
<p>Se estiver curioso, você pode ler mais detalhes <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">neste pull request</a>, mas na maior parte, este mecanismo exato não deve afetar seu código. De sua perspectiva, o novo recurso é que as pilhas de componentes agora são clicáveis ​​(porque contam com os frames de pilha do navegador nativo) e que você pode decodificá-los em produção como faria com erros regulares de JavaScript.</p>
<p>A parte que constitui uma alteração significativa é que, para que isso funcione, o React executa novamente partes de algumas das funções do React e dos construtores da classe React acima na pilha depois que um erro é capturado. Uma vez que funções de renderização e construtores de classe não devem ter efeitos colaterais (o que também é importante para a renderização de servidor), isso não deve representar nenhum problema prático.</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>Removendo exportações privadas </h3>
<p>Por fim, a última mudança importante notável é que removemos alguns componentes internos do React que foram previamente expostos a outros projetos. Em particular, <a href="https://github.com/necolas/react-native-web" target="_blank" rel="nofollow noopener noreferrer">React Native for Web</a> costumava depender de alguns componentes internos do sistema de eventos, mas essa dependência era frágil e costumava quebrar.</p>
<p><strong>No React 17, essas exportações privadas foram removidas. Pelo que sabemos, React Native for Web foi o único projeto que os utilizou, e eles já concluíram uma migração para uma abordagem diferente que não depende dessas exportações privadas.</strong></p>
<p>Isso significa que as versões anteriores do React Native for Web não serão compatíveis com o React 17, mas as versões mais recentes funcionarão com ele. Na prática, isso não muda muito porque o React Native for Web teve que lançar novas versões para se adaptar às mudanças internas do React.</p>
<p>Além disso, removemos os métodos auxiliares <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code>. Eles nunca foram documentados, não cumprem exatamente o que seus nomes indicam e não funcionam com as alterações que fizemos no sistema de eventos. Se você deseja uma maneira conveniente de disparar eventos nativos do navegador em testes, verifique a <a href="https://testing-library.com/docs/dom-testing-library/api-events" target="_blank" rel="nofollow noopener noreferrer">Biblioteca de testes do React</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>Instalação </h2>
<p>Incentivamos você a experimentar o React 17.0 Release Candidate em breve e <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">levantar quaisquer problemas</a> para os problemas que você pode encontrar na migração. <strong>Lembre-se de que um candidato a lançamento tem mais probabilidade de conter bugs do que um lançamento estável, portanto, não o implante na produção ainda.</strong></p>
<p>Para instalar o React 17 RC com npm, execute:</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>Para instalar o React 17 RC com Yarn, execute:</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>Também fornecemos compilações UMD do React por meio de um 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>Consulte a documentação para <a href="/docs/installation.html">instruções de instalação detalhadas</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>Adicione <code class="gatsby-code-text">react/jsx-runtime</code> e <code class="gatsby-code-text">react/jsx-dev-runtime</code> para que a <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">nova transformação JSX</a>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> em <a href="https://github.com/facebook/react/pull/18299" target="_blank" rel="nofollow noopener noreferrer">#18299</a>)</li>
<li>Construa pilhas de componentes a partir de quadros de erro nativos. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">#18561</a>)</li>
<li>Permite especificar <code class="gatsby-code-text">displayName</code> no contexto para pilhas melhoradas. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18224" target="_blank" rel="nofollow noopener noreferrer">#18224</a>)</li>
<li>Impedir que <code class="gatsby-code-text">'use strict'</code> vaze nos pacotes UMD. (<a href="https://github.com/koba04" target="_blank" rel="nofollow noopener noreferrer">@koba04</a> em <a href="https://github.com/facebook/react/pull/19614" target="_blank" rel="nofollow noopener noreferrer">#19614</a>)</li>
<li>Pare de usar <code class="gatsby-code-text">fb.me</code> para redirecionamentos. (<a href="https://github.com/cylim" target="_blank" rel="nofollow noopener noreferrer">@cylim</a> em <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>Delegar eventos para raízes ao invés de <code class="gatsby-code-text">document</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/18195" target="_blank" rel="nofollow noopener noreferrer">#18195</a> e <a href="https://github.com/facebook/react/pulls?q=is%3Apr+author%3Atrueadm+modern+event+is%3Amerged" target="_blank" rel="nofollow noopener noreferrer">outros</a>)</li>
<li>Limpe todos os efeitos antes de executar os próximos efeitos. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/17947" target="_blank" rel="nofollow noopener noreferrer">#17947</a>)</li>
<li>Execute as funções de limpeza <code class="gatsby-code-text">useEffect</code> de forma assíncrona. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/17925" target="_blank" rel="nofollow noopener noreferrer">#17925</a>)</li>
<li>Use o navegador <code class="gatsby-code-text">focusin</code> e <code class="gatsby-code-text">focusout</code> para <code class="gatsby-code-text">onFocus</code> e <code class="gatsby-code-text">onBlur</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/19186" target="_blank" rel="nofollow noopener noreferrer">#19186</a>)</li>
<li>Faça com que todos os eventos <code class="gatsby-code-text">Capture</code> usem a fase de captura do navegador. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/19221" target="_blank" rel="nofollow noopener noreferrer">#19221</a>)</li>
<li>Não emule o propagação do evento <code class="gatsby-code-text">onScroll</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19464" target="_blank" rel="nofollow noopener noreferrer">#19464</a>)</li>
<li>Lance se o componente <code class="gatsby-code-text">forwardRef</code> ou <code class="gatsby-code-text">memo</code> retornar <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Remova o pool de eventos. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/18969" target="_blank" rel="nofollow noopener noreferrer">#18969</a>)</li>
<li>Pare de expor detalhes internos que não serão necessários para o React Native Web. (<a href="https://github.com/necolas" target="_blank" rel="nofollow noopener noreferrer">@necolas</a> em <a href="https://github.com/facebook/react/pull/18483" target="_blank" rel="nofollow noopener noreferrer">#18483</a>)</li>
<li>Anexe todos os event listeners conhecidos quando o root for montado. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19659" target="_blank" rel="nofollow noopener noreferrer">#19659</a>)</li>
<li>Desative o <code class="gatsby-code-text">console</code> na segunda passagem de renderização do modo DEV de renderização dupla. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>Descontinue a API <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code> não documentada e confusa. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/13407" target="_blank" rel="nofollow noopener noreferrer">#13407</a>)</li>
<li>Renomeie os nomes dos campos privados usados nos internos. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/18377" target="_blank" rel="nofollow noopener noreferrer">#18377</a>)</li>
<li>Não chame a API User Timing no desenvolvimento. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/18417" target="_blank" rel="nofollow noopener noreferrer">#18417</a>)</li>
<li>Desative o console durante a renderização repetida no modo estrito. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>No Modo Estrito, os componentes de renderização dupla sem Hooks também. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18430" target="_blank" rel="nofollow noopener noreferrer">#18430</a>)</li>
<li>Permitir chamar <code class="gatsby-code-text">ReactDOM.flushSync</code> durante os métodos de ciclo de vida (mas avisar).  (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18759" target="_blank" rel="nofollow noopener noreferrer">#18759</a>)</li>
<li>Adicione a propriedade <code class="gatsby-code-text">code</code> aos objetos de evento do teclado.  (<a href="https://github.com/bl00mber" target="_blank" rel="nofollow noopener noreferrer">@bl00mber</a> em <a href="https://github.com/facebook/react/pull/18287" target="_blank" rel="nofollow noopener noreferrer">#18287</a>)</li>
<li>Adicione a propriedade <code class="gatsby-code-text">disableRemotePlayback</code> para os elementos <code class="gatsby-code-text">video</code>. (<a href="https://github.com/tombrowndev" target="_blank" rel="nofollow noopener noreferrer">@tombrowndev</a> em <a href="https://github.com/facebook/react/pull/18619" target="_blank" rel="nofollow noopener noreferrer">#18619</a>)</li>
<li>Adicione a propriedade <code class="gatsby-code-text">enterKeyHint</code> para elementos <code class="gatsby-code-text">input</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18634" target="_blank" rel="nofollow noopener noreferrer">#18634</a>)</li>
<li>Avisar quando nenhum <code class="gatsby-code-text">valor</code> é fornecido para <code class="gatsby-code-text">&lt;Context.Provider></code>. (<a href="https://github.com/charlie1404" target="_blank" rel="nofollow noopener noreferrer">@charlie1404</a> em <a href="https://github.com/facebook/react/pull/19054" target="_blank" rel="nofollow noopener noreferrer">#19054</a>)</li>
<li>Avisa quando os componentes <code class="gatsby-code-text">memo</code> ou <code class="gatsby-code-text">forwardRef</code> retornam <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Melhore a mensagem de erro para atualizações inválidas. (<a href="https://github.com/JoviDeCroock" target="_blank" rel="nofollow noopener noreferrer">@JoviDeCroock</a> em <a href="https://github.com/facebook/react/pull/18316" target="_blank" rel="nofollow noopener noreferrer">#18316</a>)</li>
<li>Exclua forwardRef e memo dos frames da pilha.  (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18559" target="_blank" rel="nofollow noopener noreferrer">#18559</a>)</li>
<li>Melhore a mensagem de erro ao alternar entre entradas controladas e não controladas. (<a href="https://github.com/vcarl" target="_blank" rel="nofollow noopener noreferrer">@vcarl</a> em <a href="https://github.com/facebook/react/pull/17070" target="_blank" rel="nofollow noopener noreferrer">#17070</a>)</li>
<li>Mantenha <code class="gatsby-code-text">onTouchStart</code>, <code class="gatsby-code-text">onTouchMove</code> e <code class="gatsby-code-text">onWheel</code> passivos. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19654" target="_blank" rel="nofollow noopener noreferrer">#19654</a>)</li>
<li>Corrigir <code class="gatsby-code-text">setState</code> pendurado em desenvolvimento dentro de um iframe fechado. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19220" target="_blank" rel="nofollow noopener noreferrer">#19220</a>)</li>
<li>Corrigir o resgate de renderização para componentes lazy com <code class="gatsby-code-text">defaultProps</code>. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> em <a href="https://github.com/facebook/react/pull/18539" target="_blank" rel="nofollow noopener noreferrer">#18539</a>)</li>
<li>Corrigir um aviso de falso positivo quando <code class="gatsby-code-text">hazouslySetInnerHTML</code> é <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/18676" target="_blank" rel="nofollow noopener noreferrer">#18676</a>)</li>
<li>Corrigir os utilitários de teste com implementação <code class="gatsby-code-text">require</code> não padrão. (<a href="https://github.com/just-boris" target="_blank" rel="nofollow noopener noreferrer">@just-boris</a> em <a href="https://github.com/facebook/react/pull/18632" target="_blank" rel="nofollow noopener noreferrer">#18632</a>)</li>
<li>Corrigir <code class="gatsby-code-text">onBeforeInput</code> relatando um <code class="gatsby-code-text">event.type</code> incorreto. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> em <a href="https://github.com/facebook/react/pull/19561" target="_blank" rel="nofollow noopener noreferrer">#19561</a>)</li>
<li>Corrigir o <code class="gatsby-code-text">event.relatedTarget</code> relatado como <code class="gatsby-code-text">undefined</code> no Firefox. (<a href="https://github.com/claytercek" target="_blank" rel="nofollow noopener noreferrer">@claytercek</a> em <a href="https://github.com/facebook/react/pull/19607" target="_blank" rel="nofollow noopener noreferrer">#19607</a></li>
<li>Corrigir “erro não especificado” no IE11. (<a href="https://github.com/hemakshis" target="_blank" rel="nofollow noopener noreferrer">@hemakshis</a> em <a href="https://github.com/facebook/react/pull/19664" target="_blank" rel="nofollow noopener noreferrer">#19664</a>)</li>
<li>Corrigir a renderização em uma root shadow. (<a href="https://github.com/Jack-Works" target="_blank" rel="nofollow noopener noreferrer">@ Jack-Works</a> em <a href="https://github.com/facebook/react/pull/15894" target="_blank" rel="nofollow noopener noreferrer">#15894</a>)</li>
<li>Corrigir polyfill <code class="gatsby-code-text">movementX / Y</code> com eventos de captura. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19672" target="_blank" rel="nofollow noopener noreferrer">#19672</a>)</li>
<li>Use a delegação para eventos <code class="gatsby-code-text">onSubmit</code> e <code class="gatsby-code-text">onReset</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/19333" target="_blank" rel="nofollow noopener noreferrer">#19333</a>)</li>
<li>Melhore o uso de memória. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <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>Servidor React DOM </h3>
<ul>
<li>Torne o comportamento <code class="gatsby-code-text">useCallback</code> consistente com <code class="gatsby-code-text">useMemo</code> para o renderizador do servidor. (<a href="https://github.com/alexmckenley" target="_blank" rel="nofollow noopener noreferrer">@alexmckenley</a> em <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> em <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>Teste Renderização React </h3>
<ul>
<li>Melhorar a mensagem de erro <code class="gatsby-code-text">findByType</code>. (<a href="https://github.com/henryqdineen" target="_blank" rel="nofollow noopener noreferrer">@henryqdineen</a> em <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>Modo simultâneo (Experimental) </h3>
<ul>
<li>Renovar as heurísticas de lote de prioridade. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18796" target="_blank" rel="nofollow noopener noreferrer">#18796</a>)</li>
<li>Adicione o prefixo <code class="gatsby-code-text">unstable_</code> antes das APIs experimentais. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remova <code class="gatsby-code-text">unstable_discreteUpdates</code> e <code class="gatsby-code-text">unstable_flushDiscreteUpdates</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remova o argumento <code class="gatsby-code-text">timeoutMs</code>. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/19703" target="_blank" rel="nofollow noopener noreferrer">#19703</a>)</li>
<li>Desabilite <code class="gatsby-code-text">&lt;div hidden /></code> pré-renderizando em favor de uma API futura diferente. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18917" target="_blank" rel="nofollow noopener noreferrer">#18917</a>)</li>
<li>Adicione <code class="gatsby-code-text">unstable_expectedLoadTime</code> no Suspense para a árvores do CPU-bound. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/19936" target="_blank" rel="nofollow noopener noreferrer">#19936</a>)</li>
<li>Adicione um Hook experimental <code class="gatsby-code-text">unstable_useOpaqueIdentifier</code>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> em <a href="https://github.com/facebook/react/pull/17322" target="_blank" rel="nofollow noopener noreferrer">#17322</a>)</li>
<li>Adicione uma API experimental <code class="gatsby-code-text">unstable_startTransition</code>. (<a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a> em <a href="https://github.com/facebook/react/pull/19696" target="_blank" rel="nofollow noopener noreferrer">#19696</a>)</li>
<li>Usar <code class="gatsby-code-text">act</code> em o renderizador de teste não libera mais os fallbacks do Suspense. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18596" target="_blank" rel="nofollow noopener noreferrer">#18596</a>)</li>
<li>Use o tempo limite de renderização global para CPU Suspense. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/19643" target="_blank" rel="nofollow noopener noreferrer">#19643</a>)</li>
<li>Limpe o conteúdo raiz existente antes de montar. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/18730" target="_blank" rel="nofollow noopener noreferrer">#18730</a>)</li>
<li>Corrija um bug com limites de erro. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18265" target="_blank" rel="nofollow noopener noreferrer">#18265</a>)</li>
<li>Corrigir um bug que causava atualizações perdidas em uma árvore suspensa. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18384" target="_blank" rel="nofollow noopener noreferrer">#18384</a> e <a href="https://github.com/facebook/react/pull/18457" target="_blank" rel="nofollow noopener noreferrer">#18457</a>)</li>
<li>Corrigir um bug que causava a queda das atualizações da fase de renderização. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18537" target="_blank" rel="nofollow noopener noreferrer">#18537</a>)</li>
<li>Corrigir um bug em SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18412" target="_blank" rel="nofollow noopener noreferrer">#18412</a>)</li>
<li>Corrigido um bug que fazia com que o recurso Suspense fosse exibido muito cedo. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18411" target="_blank" rel="nofollow noopener noreferrer">#18411</a>)</li>
<li>Corrigir um bug com componentes de classe dentro de SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18448" target="_blank" rel="nofollow noopener noreferrer">#18448</a>)</li>
<li>Corrigir um bug com entradas que podem fazer com que as atualizações sejam descartadas. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> em <a href="https://github.com/facebook/react/pull/18515" target="_blank" rel="nofollow noopener noreferrer">#18515</a> e <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18535" target="_blank" rel="nofollow noopener noreferrer">#18535</a>)</li>
<li>Corrigir um bug que fazia o fallback do Suspense travar. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18663" target="_blank" rel="nofollow noopener noreferrer">#18663</a>)</li>
<li>Não corte a cauda de um SuspenseList se estiver hidratando. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18854" target="_blank" rel="nofollow noopener noreferrer">#18854</a>)</li>
<li>Corrigir um bug em <code class="gatsby-code-text">useMutableSource</code> que pode acontecer quando<code class="gatsby-code-text">getSnapshot</code> muda. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/18297" target="_blank" rel="nofollow noopener noreferrer">#18297</a>)</li>
<li>Corrigido um bug de tearing em <code class="gatsby-code-text">useMutableSource</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/18912" target="_blank" rel="nofollow noopener noreferrer">#18912</a>)</li>
<li>Avisa se estiver chamando setState fora da renderização, mas antes do commit. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/18838" target="_blank" rel="nofollow noopener noreferrer">#18838</a>)</li>
</ul>]]></description><link>https://pt-br.reactjs.org/blog/2020/08/10/react-v17-rc.html</link><guid isPermaLink="false">https://pt-br.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://pt-br.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">react.dev/blog</a> to see the recent posts.</p>
</blockquote>
</div>
<p>Hoje estamos lançando o React 16.13.0. Ele contém correções de bugs e novos avisos de depreciação para ajudar a se preparar para uma futura versão principal.</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>Novos Avisos </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>Avisos para algumas atualizações durante a renderização </h3>
<p>Um componente React não deve causar efeitos colaterais em outros componentes durante a renderização.</p>
<p>É suportado chamar <code class="gatsby-code-text">setState</code> durante a renderização, mas <a href="/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops">somente para <em>o mesmo componente</em></a>. Se você chamar <code class="gatsby-code-text">setState</code> durante uma renderização em um componente diferente, você verá um aviso:</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><strong>Este aviso ajudará a encontrar erros de aplicativos causados ​​por alterações não intencionais do estado.</strong> Nos raros casos em que você deseja alterar intencionalmente o estado de outro componente como resultado da renderização, é possível agrupar a chamada do <code class="gatsby-code-text">setState</code> dentro do <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>Avisos para regras de estilo conflitantes </h3>
<p>Ao aplicar dinamicamente um <code class="gatsby-code-text">style</code> que contém versões <em>longhand</em> e <em>shorthand</em> de propriedades CSS, combinações específicas de atualizações podem causar estilos inconsistentes. Por exemplo: </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>Você pode esperar que essa <code class="gatsby-code-text">&lt;div></code> tenha sempre um fundo vermelho, não importa o valor de <code class="gatsby-code-text">toggle</code>. No entanto, ao alternar o valor de <code class="gatsby-code-text">toggle</code> entre <code class="gatsby-code-text">true</code> e <code class="gatsby-code-text">false</code>, a cor de fundo começa como <code class="gatsby-code-text">red</code>, então alterna entre <code class="gatsby-code-text">transparent</code> e <code class="gatsby-code-text">blue</code>, <a href="https://codesandbox.io/s/blue-water-ghx8mi" target="_blank" rel="nofollow noopener noreferrer">como você pode ver nessa demo</a>.</p>
<p><strong>O React agora detecta regras de estilo conflitantes e registra um aviso.</strong> Para corrigir um problema, não misture versões <em>shorthand</em> e <em>longhand</em> da mesma propriedade CSS na prop <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>Avisos para algumas string refs depreciadas </h3>
<p><a href="/docs/refs-and-the-dom.html#legacy-api-string-refs">String Refs é uma API legada</a> que é desencorajada e será depreciada no futuro:</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>(Não confunda String Refs com refs em geral, o que <strong>permanece totalmente suportado</strong>.)</p>
<p>No futuro, forneceremos um script automatizado (um “codemod”) para migrar para longe das referências de string. No entanto, alguns casos raros não podem ser migrados automaticamente. Esta versão adiciona um novo aviso <strong>apenas para esses casos</strong> antes da depreciação.</p>
<p>Por exemplo, ele será acionado se você usar String Refs junto com o padrão Render Prop:</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>Um código como esse geralmente indica bugs. (Você pode esperar que a ref esteja disponível em <code class="gatsby-code-text">ClassParent</code>, mas em vez disso, é colocado em <code class="gatsby-code-text">ClassWithRenderProp</code>).</p>
<p><strong>Você provavelmente não tem código como este</strong>. Se você faz e é intencional, converta-o para <a href="/docs/refs-and-the-dom.html#creating-refs"><code class="gatsby-code-text">React.createRef()</code></a> em vez de:</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>Nota</p>
<p>Para ver este aviso, você precisa ter o <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> instalado nos seus plugins Babel. Ele deve ser ativado <em>apenas</em> no modo de desenvolvimento. </p>
<p>Se você usa o Create React App ou tem a predefinição “react” com o Babel 7+, você já tem esse plug-in instalado por padrão.</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>Depreciando <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> é um helper legado para criar elementos React. Esta versão adiciona um aviso de depreciação ao método. Ele será removido em uma versão major futura.</p>
<p>Substitua os usos de <code class="gatsby-code-text">React.createFactory</code> com JSX regular. Como alternativa, você pode copiar e colar esse auxiliar de uma linha ou publicá-lo como uma biblioteca:</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>Faz exatamente a mesma coisa.</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>Depreciando <code class="gatsby-code-text">ReactDOM.unstable_createPortal</code> em favor de <code class="gatsby-code-text">ReactDOM.createPortal</code> </h3>
<p>Quando o React 16 foi lançado,<code class="gatsby-code-text">createPortal</code> tornou-se uma API oficialmente suportada.</p>
<p>No entanto, mantivemos <code class="gatsby-code-text">unstable_createPortal</code> como um alias suportado para manter as poucas bibliotecas que o adotaram funcionando. Agora estamos depreciando o alias instável. Use <code class="gatsby-code-text">createPortal</code> diretamente em vez de <code class="gatsby-code-text">unstable_createPortal</code>. Tem exatamente a mesma assinatura.</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>Outras Melhorias </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>Pilhas de componentes nos avisos de hidratação </h3>
<p>O React adiciona pilhas de componentes a seus avisos de desenvolvimento, permitindo que os desenvolvedores isolem bugs e depurem seus programas. Esta versão adiciona pilhas de componentes a vários avisos de desenvolvimento que não os tinham anteriormente. Como exemplo, considere este aviso de hidratação das versões anteriores:</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="Uma captura de tela do aviso do console, simplesmente indicando a natureza da incompatibilidade de hidratação: "Aviso: o HTML do servidor esperado deve conter uma div correspondente em 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>Embora esteja apontando um erro no código, não está claro onde o erro existe e o que fazer em seguida. Esta versão adiciona uma pilha de componentes a este aviso, o que faz com que fique assim:</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="Uma captura de tela do aviso do console, informando a natureza da incompatibilidade de hidratação, mas também incluindo uma pilha de componentes: "Aviso: o HTML do servidor esperado deve conter uma div correspondente em div, em div(no 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>Isso deixa claro onde está o problema e permite localizar e corrigir o bug mais rapidamente.</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>Correções de bugs importantes </h3>
<p>Esta versão contém algumas outras melhorias importantes:</p>
<ul>
<li>No Modo Estrito de Desenvolvimento, o React chama os métodos do ciclo de vida duas vezes para eliminar possíveis efeitos colaterais indesejados. Esta versão adiciona esse comportamento a <code class="gatsby-code-text">shouldComponentUpdate</code>. Isso não deve afetar a maioria dos códigos, a menos que você tenha efeitos colaterais em <code class="gatsby-code-text">shouldComponentUpdate</code>. Para corrigir isso, mova o código com efeitos colaterais para <code class="gatsby-code-text">componentDidUpdate</code>.</li>
<li>No Modo Estrito de Desenvolvimento, os avisos para o uso da API de contexto legada não incluíam a pilha do componente que acionou o aviso. Esta versão adiciona a pilha ausente ao aviso.</li>
<li><code class="gatsby-code-text">onMouseEnter</code> agora não é disparado em elementos <code class="gatsby-code-text">&lt;button></code> desabilitados.</li>
<li>O ReactDOM tinha uma exportação de <code class="gatsby-code-text">version</code> ausente desde que publicamos a v16. Esta versão adiciona de volta. Não recomendamos o uso na lógica do aplicativo, mas é útil ao depurar problemas com incompatibilidade / várias versões do ReactDOM na mesma página.</li>
</ul>
<p>Agradecemos a todos os colaboradores que ajudaram a resolver e solucionar esses e outros problemas. Você pode encontrar o changelog completo <a href="#changelog">abaixo</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>Instalação </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>O React v16.13.0 está disponível no registro npm.</p>
<p>Para instalar o React 16 com o Yarn, execute:</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>Para instalar o React 16 com npm, execute:</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>Também fornecemos compilações UMD do React por meio de uma 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>Consulte a documentação para <a href="/docs/installation.html">instruções detalhadas de instalação</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>Avisa quando uma string ref é usada de uma maneira que não seja compatível com um futuro codemod (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> in <a href="https://github.com/facebook/react/pull/17864" target="_blank" rel="nofollow noopener noreferrer">#17864</a>)</li>
<li>Deprecia <code class="gatsby-code-text">React.createFactory()</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <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>Avisa quando houver alterações <code class="gatsby-code-text">style</code> podem causar uma colisão inesperada (<a href="https://github.com/sophiebits" target="_blank" rel="nofollow noopener noreferrer">@sophiebits</a> em <a href="https://github.com/facebook/react/pull/14181" target="_blank" rel="nofollow noopener noreferrer">#14181</a>, <a href="https://github.com/facebook/react/pull/18002" target="_blank" rel="nofollow noopener noreferrer">#18002</a>)</li>
<li>Avisa quando um componente de função é atualizado durante a fase de renderização de outro componente (<a href="(https://github.com/acdlite)">@acdlite</a> em <a href="https://github.com/facebook/react/pull/17099" target="_blank" rel="nofollow noopener noreferrer">#17099</a>)</li>
<li>Depreciado <code class="gatsby-code-text">unstable_createPortal</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/17880" target="_blank" rel="nofollow noopener noreferrer">#17880</a>)</li>
<li>Conserta <code class="gatsby-code-text">onMouseEnter</code> sendo acionado nos botões desativados (<a href="https://github.com/AlfredoGJ" target="_blank" rel="nofollow noopener noreferrer">@AlfredoGJ</a> em <a href="https://github.com/facebook/react/pull/17675" target="_blank" rel="nofollow noopener noreferrer">#17675</a>)</li>
<li>Chama <code class="gatsby-code-text">shouldComponentUpdate</code> duas vezes ao desenvolver em <code class="gatsby-code-text">StrictMode</code> (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/17942" target="_blank" rel="nofollow noopener noreferrer">#17942</a>)</li>
<li>Adiciona propriedade <code class="gatsby-code-text">version</code> para ReactDOM (<a href="https://github.com/ealush" target="_blank" rel="nofollow noopener noreferrer">@ealush</a> em <a href="https://github.com/facebook/react/pull/15780" target="_blank" rel="nofollow noopener noreferrer">#15780</a>)</li>
<li>Não chamar <code class="gatsby-code-text">toString()</code> em <code class="gatsby-code-text">dangerouslySetInnerHTML</code> (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/17773" target="_blank" rel="nofollow noopener noreferrer">#17773</a>)</li>
<li>Mostra pilhas de componentes em mais avisos (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/17922" target="_blank" rel="nofollow noopener noreferrer">#17922</a>, <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>Modo Concorrente (Experimental) </h3>
<ul>
<li>Avisa sobre usos problemáticos de <code class="gatsby-code-text">ReactDOM.createRoot()</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/17937" target="_blank" rel="nofollow noopener noreferrer">#17937</a>)</li>
<li>Retira <code class="gatsby-code-text">ReactDOM.createRoot()</code> parâmetros de retorno de chamada e avisos adicionais sobre o uso (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> em <a href="https://github.com/facebook/react/pull/17916" target="_blank" rel="nofollow noopener noreferrer">#17916</a>)</li>
<li>Não agrupe o trabalho ocioso / fora da tela com outro trabalho (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/17456" target="_blank" rel="nofollow noopener noreferrer">#17456</a>)</li>
<li>Ajusta heurística de limite de processamento do <code class="gatsby-code-text">SuspenseList</code> (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <a href="https://github.com/facebook/react/pull/17455" target="_blank" rel="nofollow noopener noreferrer">#17455</a>)</li>
<li>Adiciona prioridades de plugins de eventos ausentes (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> em <a href="https://github.com/facebook/react/pull/17914" target="_blank" rel="nofollow noopener noreferrer">#17914</a>)</li>
<li>Conserta <code class="gatsby-code-text">isPending</code> somente sendo verdadeiro ao fazer a transição de dentro de um evento de input (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/17382" target="_blank" rel="nofollow noopener noreferrer">#17382</a>)</li>
<li>Conserta componentes <code class="gatsby-code-text">React.memo</code> que descartam atualizações quando interrompidos por uma atualização de prioridade mais alta (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> em <a href="https://github.com/facebook/react/pull/18091" target="_blank" rel="nofollow noopener noreferrer">#18091</a>)</li>
<li>Não avise ao suspender com a prioridade errada (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> em <a href="https://github.com/facebook/react/pull/17971" target="_blank" rel="nofollow noopener noreferrer">#17971</a>)</li>
<li>Corrige um bug com atualizações de rebasing (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> e <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> em <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>, <a href="https://github.com/facebook/react/pull/17480" target="_blank" rel="nofollow noopener noreferrer">#17480</a>)</li>
</ul>]]></description><link>https://pt-br.reactjs.org/blog/2020/02/26/react-v16.13.0.html</link><guid isPermaLink="false">https://pt-br.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>