<?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://ja.reactjs.org</link><generator>GatsbyJS</generator><lastBuildDate>Thu, 19 Oct 2023 14:52:28 GMT</lastBuildDate><item><title><![CDATA[React Labs: 私達のこれまでの取り組み - 2022年6月版]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</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> の完成は数年がかりの仕事であり、React チームはそこから貴重な教訓を得ることになりました。このリリースは何年も研究を行い、様々なアプローチを試した結果として生まれたものです。いくつかのアプローチはうまく行った一方で、多くは行き詰まって新たな知見のみをもたらすことになりました。ここから我々が学んだことは、我々がどんなことを試しているのかをコミュニティに知らせることなくただお待たせするというのは、フラストレーションの元だ、ということです。</p>
<p>我々は、かなり実験的なものから明確に定義されているものまで、ほぼ常に様々なプロジェクトを同時に進めています。今後は、これらのプロジェクトに関する我々の取り組みについて、より多くのことを定期的にコミュニティと共有していくようにしたいと思います。</p>
<p>あらかじめ申しあげておくと、この記事は明確なタイムラインのあるロードマップではありません。以下に挙げるプロジェクトの多くはまだ活発に探求中のものであり、具体的なリリース日を設定することは困難です。我々の学びの結果次第では、そもそも現在のイテレーションではリリースされないという可能性すらあります。その代わりここでは、現在まさに我々が何を問題と考えており、現時点でどこまでを学んだのかについて、共有していきたいと思います。</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>サーバコンポーネント </h2>
<p>2020 年 12 月に、<a href="https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html" target="_blank" rel="nofollow noopener noreferrer">React サーバコンポーネント (RSC) に関する実験的なデモ</a>を発表しました。それ以降、必要となる準備作業を React 18 で済ませ、実験のフィードバックから得られた改善に取り組んできました。</p>
<p>特に、I/O ライブラリをフォークして例えば react-fetch のようなものを作成していく、というアイディアは捨て去ることにし、代わりに互換性のために async/await モデルを採用することにします。データフェッチングにはルータを使うこともできるのでこれにより RSC のリリースが遅れるということはありません。もうひとつの変更は、ファイルの拡張子でサーバコンポーネントかどうかを区別するというアプローチをやめ、<a href="https://github.com/reactjs/rfcs/pull/189#issuecomment-1116482278" target="_blank" rel="nofollow noopener noreferrer">区別を注釈で行う</a>ことにする、というものです。</p>
<p>Webpack と Vite の両方で振る舞いが同じになるようバンドラのサポートを共通化することについて、Vercel および Shopify とともに取り組んでいます。リリース前に、React のエコシステム全体で RSC の振る舞いが同じになるようにしたいと考えています。この部分が安定化前の最大の障壁となっています。</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>アセットのロード </h2>
<p>現在のところ、スクリプトや外部スタイル・フォント・画像のようなアセットは、典型的には外部のシステムを通じてプリロードあるいはロードされています。しかしこれにより、ストリーミングやサーバコンポーネントといった新たな環境でうまく動くようにするのが難しくなることがあります。
あらゆる React の環境で動作する API を追加し、それを通じて外部に分離されたアセットをプリロードあるいはロードできるよう、検討を進めています。</p>
<p>また、この新たな API がサスペンスをサポートすることで、画像や CSS やフォントを使っても、これらがロードされるまで表示はブロックするがストリーミングや並列レンダーはブロックしない、というようにしたいと考えています。これにより、画面上の要素がポップしレイアウトがずれるという<a href="https://twitter.com/sebmarkbage/status/1516852731251724293" target="_blank" rel="nofollow noopener noreferrer">「ポップコーン」現象</a>を防ぐことができます。</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>サーバレンダリングの静的な最適化 </h2>
<p>Static Site Generation (SSG) と Incremental Static Regeneration (ISR) はキャッシュ可能なページにおいてパフォーマンスを向上するための素晴らしい手法です。が、ダイナミックなサーバサイドレンダリング (SSR) についてもパフォーマンス改善のために何らかの機能を追加できるのではと考えています。特に、全コンテンツのキャッシュはできないが大部分は可能という状況について検討しています。コンパイルや静的パスを用いてサーバレンダリングを最適化する方法について、探索を行っています。</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 最適化コンパイラ </h2>
<p>React Conf 2021 において、React Forget についての<a href="https://www.youtube.com/watch?v=lGEMwh32soc" target="_blank" rel="nofollow noopener noreferrer">アーリープレビュー</a>をお届けしました。これは、React のプログラミングモデルを保ちつつ、<code class="gatsby-code-text">useMemo</code> や <code class="gatsby-code-text">useCallback</code> の同等物を自動で作成して再レンダーのコストを最小化するためのコンパイラです。</p>
<p>最近になって、このコンパイラの安定性と機能を向上するための書き直しが完了しました。新しいアーキテクチャは、<a href="https://react.dev/learn/keeping-components-pure#local-mutation-your-components-little-secret" target="_blank" rel="nofollow noopener noreferrer">ローカルでの変数書き換え</a>のような、より複雑なパターンも解析してメモ化を適用することが可能であり、単にメモ化用フックと同じ事ができるという以上に、様々なコンパイル時最適化の可能性を開くことができます。</p>
<p>また、このコンパイラの様々な機能について試すためのプレイグラウンドを作成しています。プレイグラウンドの主目的はコンパイラ自体の開発をやりやすくすることですが、コンパイラを試して何をやっているのか直観で理解できるようにすることにも役立つと考えています。これにより裏で何をやっているのか洞察できるようになりますし、タイプして即座にコンパイル出力を見ることもできるようになります。こちらはコンパイラのリリースの際に同時にリリースされる予定です。</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>オフスクリーン </h2>
<p>現在のところ、コンポーネントを非表示にしたり表示したりしたい場合、選択肢はふたつあります。ひとつは、ツリーから完全に削除するというものです。これによる問題は、アンマウントするたびに UI の state や、DOM 内に保持されているスクロール位置のような状態が失われてしまうことです。</p>
<p>もうひとつの選択肢は、コンポーネントをマウントしたままで CSS を使って表示・非表示を切り替える、というものです。これにより UI の state は保持されますが、React は非表示のコンポーネントやその子コンポーネントに更新があったときにそれをレンダーし続ける必要があるため、パフォーマンス面ではコストがかかります。</p>
<p>オフスクリーン (offscreen) 機能は第 3 の選択肢を提供します。UI を見た目に非表示とした上で、内容の更新の優先度を下げるのです。これは考え方の点では <code class="gatsby-code-text">content-visibility</code> CSS プロパティと似ています。コンテンツが非表示の場合、UI 内の他の要素と同期をとる必要はありません。React はレンダー作業を、アプリがアイドル状態になるかコンテンツが再び表示されるようになるまで遅延させることができます。</p>
<p>オフスクリーン機能は、高レベルの機能を実現するための低レベル機能です。<code class="gatsby-code-text">startTransition</code> のような React の他の並行レンダー機能と同様ですが、大抵の場合、あなたが直接オフスクリーン API を利用することはありません。代わりに、フレームワークが実装する以下のようなパターンを通じて利用することになるでしょう。</p>
<ul>
<li><strong>即時の画面遷移。</strong>現在でもルーティングフレームワークの中にはナビゲーションを高速化するため、リンクをホバーした際などにデータをプリフェッチするものが存在します。オフスクリーン機能を使えば、さらに後続の画面をバックグラウンドでプリレンダーしておくことが可能になります。</li>
<li><strong>ステートの再利用。</strong>同様に、オフスクリーン機能を使うことで、ページやタブを切り替えた時に前の画面の state を保持しておき、切り替えて戻ってきたときに前の状況を復元できるようになります。</li>
<li><strong>リストのレンダーの仮想化。</strong>大きなリストを表示している際に、リスト仮想化を提供するフレームワークでは現在見えているもの以外にも多くの項目をプリレンダーします。オフスクリーン機能を使えば、見えていない項目をリスト内の見えている項目よりも低優先度でプリレンダーすることができるようになります。</li>
<li><strong>背景コンテンツ。</strong>また、モーダルをオーバーレイで表示している場合の背景要素など、非表示でないコンテンツのレンダー優先度を下げるような関連機能についても検討しています。</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>トランジションのトレース </h2>
<p>現在 React にはプロファイリングのためのツールがふたつ存在します。<a href="https://reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html" target="_blank" rel="nofollow noopener noreferrer">オリジナルのプロファイラ</a>は、プロファイリングセッション中に起こったすべてのコミットについて概要を表示します。それぞれのコミットに対して、レンダーされた全コンポーネントとレンダーにかかった時間も表示します。これと別に、React 18 で導入された<a href="https://github.com/reactwg/react-18/discussions/76" target="_blank" rel="nofollow noopener noreferrer">タイムラインプロファイラ</a>のベータ版も存在します。これはコンポーネントのスケジュールの変化や React が更新をいつ行うのかについての情報を表示します。これらのプロファイラはいずれも、開発者がコード内のパフォーマンスに関する問題を特定するのに役立ちます。</p>
<p>我々は、文脈なしに個々の遅いコミットやコンポーネントに関する情報だけ分かったところで開発者にとってはさほど役立たない、ということを学びました。知りたい情報は、現に遅いコミットになってしまっている理由の方です。開発者は、ボタンクリック、初回ロード、ページ移動といった特定の操作を追跡してパフォーマンスの悪化を監視し、なぜ操作が遅かったのか、どのように修正するのかを知りたいのです。</p>
<p>この問題を解決するために、以前 <a href="https://gist.github.com/bvaughn/8de925562903afd2e7a12554adcdda16" target="_blank" rel="nofollow noopener noreferrer">Interaction Tracing API</a> の作成を試みたことがありますが、これには根本的な設計の問題があったため、操作が遅い理由を正確に知ることが難しく、場合によっては操作が全く終わらなくなってしまうこともありました。このため<a href="https://github.com/facebook/react/pull/20037" target="_blank" rel="nofollow noopener noreferrer">この API は削除</a>せざるを得ませんでした。</p>
<p>現在、この問題を解決するための Interaction Tracing API の新バージョン（<code class="gatsby-code-text">startTransition</code> で起動するので Transition Tracing と仮に呼んでいます）に取り組んでいます。</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>新たな React ドキュメント </h2>
<p>昨年、新たな React のドキュメントサイトの<a href="https://react.dev/" target="_blank" rel="nofollow noopener noreferrer">ベータ版</a>を発表しました。この新たな教材ではフックを優先的に学ぶことができ、新たな図やイラスト、インタラクティブに試せる例やチャレンジ問題が存在します。React 18 のリリースに集中するために作業をしばらくお休みしていましたが、React 18 のリリースも終わりましたので、新ドキュメントの仕上げとリリースに活発に取り組んでいます。</p>
<p>副作用 (effect) は新規ユーザにとっても経験のあるユーザにとっても難しいトピックのひとつだと聞いていますので、現在我々は副作用についての詳細な説明を準備中です。<a href="https://react.dev/learn/synchronizing-with-effects" target="_blank" rel="nofollow noopener noreferrer">Synchronizing with Effects</a> が一連の記事のうちで最初に公開されているものですが、これからの数週間でより多くが公開される予定です。また副作用についての詳細な記事を書き始めたことで、副作用に関するよくあるパターンの多くは、React に基本機能を加えることでシンプルにできる、ということに気付きました。初期アイディアの一部は <a href="https://github.com/reactjs/rfcs/pull/220" target="_blank" rel="nofollow noopener noreferrer">useEvent RFC</a> で共有されています。これはまだ初期の研究段階でありアイディアについて見直しをしているところです。RFC にコメントを寄せてくださったコミュニティの方々や、ドキュメントの書き直しに関して<a href="https://github.com/reactjs/reactjs.org/issues/3308" target="_blank" rel="nofollow noopener noreferrer">フィードバック</a>や貢献をしてくださった方に感謝します。特に新サイトの実装に関して多くのレビューや改善を寄せてくださった <a href="https://github.com/harish-sethuraman" target="_blank" rel="nofollow noopener noreferrer">Harish Kumar</a> に感謝します。</p>
<p><em class="em-ja">このブログ記事のレビューをしてくださった <a href="https://twitter.com/sophiebits" target="_blank" rel="nofollow noopener noreferrer">Sophie Alpert</a> に感謝します。</em></p>]]></description><link>https://ja.reactjs.org/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022.html</link><guid isPermaLink="false">https://ja.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>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p>React 18 が npm で利用可能になりました！</p>
<p>前回の投稿にて、<a href="/blog/2022/03/08/react-18-upgrade-guide.html">アプリを React 18 にアップグレードする</a>ためのステップバイステップガイドを共有しました。この投稿では、React 18 の新機能や、将来に向けての展望をお伝えします。</p>
<p>この最新のメジャーバージョンには、自動バッチング (automatic batching) のような自動で有効になる機能改善、startTransition のような新たな API、そしてサスペンス (suspense) に対応したストリーミングでのサーバサイドレンダリング機能が含まれています。</p>
<p>React 18 の機能の多くが基盤としているのは新たに加わった並行レンダラ (concurrent renderer) であり、これが強力な新機能群を実現するために裏で働くようになっています。React の並行処理機能はオプトインであり、並行処理機能を使う場合にのみ有効になるものですが、これは皆さんのアプリ作成方法に大きな影響を与えるものであると思っています。</p>
<p>我々は React で並行処理をサポートするために何年ものあいだ研究開発を重ねてきており、特に既存ユーザが段階的に採用できる方法を提供することに関しては注意を払ってきました。昨年の夏に <a href="https://reactjs.org/blog/2021/06/08/the-plan-for-react-18.html" target="_blank" rel="nofollow noopener noreferrer">React 18 ワーキンググループ</a>を作成し、エキスパートやコミュニティからフィードバックを集め、React のエコシステム全体がスムースにアップグレードできるようにしてきました。</p>
<p>また、React Conf 2021 でも多くのことを共有してきました。</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa" target="_blank" rel="nofollow noopener noreferrer">キーノート</a>では、素晴らしいユーザ体験を開発者が簡単に構築できるようにするという我々の使命に React 18 がどう関わるのかについて説明しています。</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">React 18 の新機能の使い方についてデモを行っています</a>。</li>
<li><a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</a> は<a href="https://www.youtube.com/watch?v=pj5N-Khihgc&#x26;list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa&#x26;index=3" target="_blank" rel="nofollow noopener noreferrer">サスペンスを用いたストリーミングサーバレンダリング</a>についての概要を説明しています。</li>
</ul>
<p>以下が、並行レンダー機能をはじめとする、このリリースで期待される新要素の概要です。</p>
<p><em class="em-ja">React Native ユーザ向けの注意：React 18 は新たなアーキテクチャの React Native の一部としてリリースされます。詳細については<a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;t=1530s" target="_blank" rel="nofollow noopener noreferrer">こちらの React Conf キーノート</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>React の並行処理機能とは？ </h2>
<p>React 18 で加わった中で最も重要なものとはすなわち「並行処理機能」ですが、これはできることなら皆さんが全く考えないで済むのが望ましいことです。ただしアプリケーション開発者にとっては概ねその通りでしょうが、ライブラリのメンテナにとっては話はちょっと複雑かもしれません。</p>
<p>並行処理は、それ自体が何か機能だというわけではありません。これは、同時に UI の複数のバージョンを React が準備しておけるようにするための、新たな裏方のメカニズムです。並行処理機能そのものは実装の詳細 (implementation detail) に過ぎず、それが有用なのはそれで実現できる様々な機能が存在するからこそだ、と考えてください。React は内部の実装において priority queue や multiple buffering などの洗練された手法を用いています。ですがこれらのコンセプトは公開 API のどこにも現れません。</p>
<p>我々が API を設計する際には、開発者に実装の詳細を見せないように努力しています。React 開発者としてみなさんはユーザ体験を<em class="em-ja">どんな</em>見た目にしたいかを考えることに集中し、その見た目を<em class="em-ja">どのように</em>実現するのかは React が受け持ちます。React 開発者が、裏で並行処理機能がどのように働いているのかを知る必要はありません。</p>
<p>しかし、React の並行処理機能は、普通の「実装の詳細」と比べてより重要なものであり、React のコアのレンダリングモデルに対する本質的な変更です。ですので並行処理の動作について詳しく知ることがもの凄く重要ということではないにせよ、どのようなものかについて高レベルの概観を知っておくことは有用かもしれません。</p>
<p>React の並行処理機能の重要な特性は、処理を中断可能であるということです。React 18 にアップグレードしても、何らかの並行処理機能を加えるまでは、更新は React の以前のバージョンと同じく、まとめて、中断されず、かつ同期的にレンダーされます。同期的なレンダーでは、更新のレンダーが始まったら、ユーザが結果を画面で見られるようになるまでそれを中断することはできません。</p>
<p>並行レンダーにおいては、これが必ずしも正しくなくなります。React は更新のレンダーを開始し、途中で一時停止し、後で再開することができます。途中まで終わったレンダーを完全に捨ててしまうこともありえます。レンダーが中断したとしても、React は UI の見た目に一貫性があることを保証します。これを実現するために、React はツリー全体の評価が終わるまで DOM の書き換えをせずに待機します。これにより、React はメインスレッドをブロックせずにバックグラウンドで次の画面を用意しておけるようになります。つまり、大きなレンダー作業の最中でもユーザの入力に UI が即座に反応できるということであり、ユーザ体験がスムースになります。</p>
<p>もう 1 つの例は、state の再利用です。React の並行処理機能により、画面から UI の一部分をいったん削除し、前回の state を再利用しながら後で戻す、ということが可能です。例えば、ユーザがタブを切り替えて画面から離れて戻ってきた場合、React は以前の画面を以前と同様の state で復帰させる必要があります。将来のマイナーリリースにおいて、このパターンを実装した <code class="gatsby-code-text">&lt;Offscreen></code> というコンポーネントを新たに加える予定です。同様に、<code class="gatsby-code-text">&lt;Offscreen></code> を使ってバックグラウンドで新しい UI を用意し、ユーザが表示させようとする前に準備完了にしておく、ということもできるようになるでしょう。</p>
<p>並行レンダーは React における新しいパワフルなツールであり、サスペンス、トランジション、ストリーミング付きサーバーレンダリングといった新たな機能のほとんどはこれを活用して構築されています。しかし React 18 はこの新しい基盤の上に我々が構築しようとしているものの始まりに過ぎません。</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>並行処理機能の段階的な採用 </h2>
<p>厳密には、並行レンダーは破壊的変更です。並行レンダーは中断可能なため、それが有効になるとコンポーネントはわずかに異なった動作をします。</p>
<p>我々はテストにおいて、数千のコンポーネントを React 18 のためにアップグレードしました。そこで分かったことは、ほとんどすべての既存のコンポーネントは並行レンダーにおいても「普通に」動作するということです。しかしいくつかのコンポーネントでは移行のための追加作業が必要です。変更は通常小さなものですが、自分のペースで更新作業を行うことも可能です。React 18 の新たなレンダーの挙動は、<strong>あなたのアプリ内で新機能を使っている部分でのみ有効化されます</strong>。</p>
<p>大まかな移行作業の流れとしては、まず既存コードの挙動を壊さずにアプリが React 18 で動作するようにします。それから自分のペースで並行処理機能を徐々に追加し始めることができます。<a href="/docs/strict-mode.html"><code class="gatsby-code-text">&lt;StrictMode></code></a> を利用すれば、並行処理に関連するバグに開発時に気付きやすいようにできます。strict モードは本番での動作に影響を与えませんが、開発中には追加の警告を表示したり、べき等 (idempotent) であるべき関数を 2 回呼び出したりします。すべての間違いを捕捉することはできませんが、最もよくある間違いを防ぐのに効果的です。</p>
<p>React 18 にアップグレード後、並行処理機能をすぐに使い始めることができます。例えばユーザの入力をブロックせずに画面遷移を行うために startTransition を使うことができます。あるいは高価な再レンダーの頻度を落とすために useDeferredValue を使うことも可能です。</p>
<p>しかし長期的には、あなたのアプリに並行処理を加えるためのメインの方法は、並行処理に対応したライブラリやフレームワークを使うことになるだろうと考えています。ほとんどの場合、あなたが並行処理の API を直接触ることはないはずです。例えば新しい画面に遷移するたびに毎回開発者が startTransition をコールするのではなく、ルータのライブラリがナビゲーションを startTransition で自動でラップするようになるでしょう。</p>
<p>ライブラリがアップグレードされて並行処理機能対応になるまでには、多少時間がかかるかもしれません。並行処理機能をライブラリが活用しやすくするために新しい API を提供しています。当面は、React エコシステムが徐々に移行していくまで、ライブラリメンテナが作業するのをお待ちください。</p>
<p>詳細は、前回の投稿をご覧ください：<a href="https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html" target="_blank" rel="nofollow noopener noreferrer">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>データフレームワークにおけるサスペンス </h2>
<p>React 18 では、Relay、Next.js、Hydrogen、Remix のような、使い方の規約がある (opinionated) フレームワークにおいて、データ取得のためのサスペンスを使い始めることができます。単発的なデータ取得にサスペンスを使うことも技術的には可能ですが、現時点では一般的な戦略としてはお勧めしません。</p>
<p>将来的には、上記のようなフレームワークを用いなくてもあなたのデータにサスペンスを使ってアクセスしやすくするため、新たに基本機能を提供するかもしれません。しかしサスペンスは、ルータやデータレイヤ、サーバレンダリング環境といったあなたのアプリのアーキテクチャと深く結合して利用される場合に、最も効果を発揮します。長期的にも、ライブラリやフレームワークが React のエコシステムにおいて重要な働きをすることを期待しています。</p>
<p>React の以前のバージョンと同様、サスペンスはクライアントで React.lazy を使ってコードを分割する際にも利用できます。しかし我々がサスペンスを使って実現したいと構想しているのは、コードのロードよりもずっと多くのことです。目標は、サスペンスのサポートを拡張していき、いずれはサスペンスによるひとつの宣言的なフォールバックが、あらゆる非同期的な操作（コード、データ、画像などのロード）を扱えるようにすることです。</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>サーバコンポーネントはまだ開発中です </h2>
<p><a href="/blog/2020/12/21/data-fetching-with-react-server-components.html"><strong>サーバコンポーネント</strong></a> は実装予定の機能であり、クライアントサイドアプリにおけるリッチなインタラクティビティと伝統的なサーバレンダリングによるパフォーマンス改善とを兼ね備えた、クライアント・サーバ両方にまたがるアプリの開発を可能にするものです。サーバコンポーネントは React の並行処理機能と本質的に結合してはいませんが、サスペンスやストリーミングサーバレンダリングのような並行処理機能と併用した際に最もうまく働くようデザインされています。</p>
<p>サーバコンポーネントはまだ実験的機能ですが、18.x のマイナーリリースで初期バージョンをリリースできる見込みです。それまでは、プロポーザルを推し進めて広く採用できる準備が整うよう、Next.js、Hydrogen、Remix のようなフレームワークと協力していきます。</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>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>新機能：自動バッチング </h3>
<p>バッチングとは React がパフォーマンスのために複数のステート更新をグループ化して、単一の再レンダーにまとめることを指します。自動バッチング以前は、React のイベントハンドラ内での更新のみバッチ処理されていました。promise や setTimeout、ネイティブのイベントハンドラやその他あらゆるイベント内で起きる更新はデフォルトではバッチ処理されていませんでした。自動バッチングにより、これらの更新も自動でバッチ処理されるようになります：</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>詳細については、<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>新機能：トランジション </h3>
<p>トランジション（transition; 段階的推移）とは React における新たな概念であり、緊急性の高い更新 (urgent update) と高くない更新 (non-urgent update) を区別するためのものです。</p>
<ul>
<li><strong>緊急性の高い更新</strong>とはタイプ、クリック、プレスといったユーザ操作を直接反映するものです。</li>
<li><strong>トランジションによる更新</strong>は UI をある画面から別の画面に段階的に遷移させるものです。</li>
</ul>
<p>タイプ、クリック、プレスのような緊急性の高い更新は、物理的な物体の挙動に関する我々の直観に反しないよう、即座に反応する必要があり、そうでないと「おかしい」と認識されてしまいます。一方でトランジション内では、ユーザは画面上であらゆる中間の値が見えることを期待していません。</p>
<p>例えば、ドロップダウン内でフィルタを選択した場合、フィルタボタン自体はクリックした瞬間に反応することを期待するでしょう。しかしフィルタの結果は、ボタンの反応とは別に徐々に現れても構いません。小さな遅延は認識できませんし、あって構わないものです。また、前のレンダーが終わっていない段階で再びフィルタを変更した場合、最終的な結果以外は気にしません。</p>
<p>典型的には、最良のユーザ体験のためには、あるひとつのユーザ入力は緊急性の高い更新と高くない更新の両方を引き起こすようにするべきです。input イベント内で startTransition API を用い、React にどの更新の緊急性が高く、どれが「トランジション」なのかを伝えることができます：</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>startTransition でラップした更新は緊急性の低いものとして扱われ、クリックやキー押下のような緊急性の高い更新がやってきた場合には中断されます。トランジションがユーザによって中断された場合（例えば素早く複数のタイプが起こった場合）、React は完了しないままに古くなったレンダーを破棄して、最後の更新のみレンダーします。</p>
<ul>
<li><code class="gatsby-code-text">useTransition</code>: トランジションを開始するためのフックであり、保留中かどうかの状態を追跡するための値も含まれます。</li>
<li><code class="gatsby-code-text">startTransition</code>: フックが使えない場合にトランジションを開始するためのメソッドです。</li>
</ul>
<p>トランジションを使うと並行レンダー機能にオプトインし、更新が中断可能になります。また、コンテンツが再サスペンドした場合、バックグラウンドでトランジション中のコンテンツをレンダーしつつ、現在のコンテンツを表示し続けるよう React に伝えます（詳細については <a href="https://github.com/reactjs/rfcs/blob/main/text/0213-suspense-in-react-18.md" target="_blank" rel="nofollow noopener noreferrer">サスペンス RFC</a> を参照）。</p>
<p><a href="/docs/react-api.html#transitions">トランジションのドキュメントはこちら</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>サスペンスの新機能 </h3>
<p>サスペンスにより、コンポーネントツリーの一部がまだ表示できない場合に、ロード中という状態を宣言的に記述できるようになります：</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>サスペンスにより、「UI ロード中状態」というものが、React のプログラミングモデルで宣言的に記述可能な主要コンセプトに昇格します。その上により高レベルな機能を構築していけるようになります。</p>
<p>我々は数年前に機能限定版のサスペンスを導入しました。しかしサポートされているユースケースは React.lazy によるコード分割のみであり、サーバでのレンダーにおいては一切サポートされていませんでした。</p>
<p>React 18 ではサーバ側でのサスペンスのサポートを追加し、並行レンダリング機能を用いてその能力を向上させました。</p>
<p>React 18 におけるサスペンスはトランジション API と併用した場合に能力を発揮します。トランジション中でサスペンドが発生すると、React は既に見えているコンテンツがフォールバックによって隠されてしまわないようにするのです。代わりに、十分なデータがロードされるまでレンダーを遅らせて、望ましくないロード中状態が見えないようにします。</p>
<p>詳しくは、<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> の RFC を参照してください。</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>新たなクライアントおよびサーバ用のレンダー API </h3>
<p>このリリースを機に、クライアントおよびサーバ用に公開している API を再設計することにしました。これにより React 18 の新しい API にアップグレードするまでの間、React 17 の古い API を利用し続けることができるようになります。</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>以下の新たな API は <code class="gatsby-code-text">react-dom/client</code> からエクスポートされるようになっています：</p>
<ul>
<li><code class="gatsby-code-text">createRoot</code>: <code class="gatsby-code-text">render</code> したり <code class="gatsby-code-text">unmount</code> したりできる新たなルートを作成するための新メソッドです。<code class="gatsby-code-text">ReactDOM.render</code> の代わりに利用してください。これを使わないと React 18 の新機能は動作しません。</li>
<li><code class="gatsby-code-text">hydrateRoot</code>: サーバでレンダーされたアプリをハイドレーションするための新メソッドです。<code class="gatsby-code-text">ReactDOM.hydrate</code> の代わりに、新たな React DOM サーバ API と併せて利用してください。これを使わないと React 18 の新機能は動作しません。</li>
</ul>
<p><code class="gatsby-code-text">createRoot</code> と <code class="gatsby-code-text">hydrateRoot</code> のいずれも、<code class="gatsby-code-text">onRecoverableError</code> という新たなオプションを受け取るようになっており、レンダーあるいはハイドレーション中に起きたエラーから React が復帰した場合に通知を受けてログを残したい場合に利用できます。デフォルトでは React は <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> か、古いブラウザの場合は <code class="gatsby-code-text">console.error</code> を利用します。</p>
<p><a href="/docs/react-dom-client.html">React DOM Client のドキュメントはこちら</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>以下の新たな API は <code class="gatsby-code-text">react-dom/client</code> からエクスポートされるようになっており、サーバでサスペンスをストリーミングする機能を完全にサポートしています：</p>
<ul>
<li><code class="gatsby-code-text">renderToPipeableStream</code>: Node 環境でのストリーミング用。</li>
<li><code class="gatsby-code-text">renderToReadableStream</code>: Deno や Cloudflare Workers のようなモダンなエッジランタイム環境用。</li>
</ul>
<p>既存の <code class="gatsby-code-text">renderToString</code> メソッドは今後も動作しますが、推奨されません。</p>
<p><a href="/docs/react-dom-server.html">React DOM Server のドキュメントはこちら</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>Strict モードの新たな挙動 </h3>
<p>将来的に、React が state を保ったままで UI の一部分を追加・削除できるような機能を導入したいと考えています。例えば、ユーザがタブを切り替えて画面を離れてから戻ってきた場合に、React が以前の画面をすぐに表示できるようにしたいのです。これを可能にするため、React は同じ state を使用してツリーをアンマウント・再マウントします。</p>
<p>この機能により、React の標準状態でのパフォーマンスが向上しますが、コンポーネントは副作用が何度も登録されたり破棄されたりすることに対して耐性を持つことが必要になります。ほとんどの副作用は何の変更もなく動作しますが、一部の副作用は一度しか登録・破棄されないものと想定しています。</p>
<p>この問題に気付きやすくするために、React 18 は strict モードに新しい開発時専用のチェックを導入します。この新しいチェックは、コンポーネントが初めてマウントされるたびに、すべてのコンポーネントを自動的にアンマウント・再マウントし、かつ 2 回目のマウントで以前の state を復元します。</p>
<p>これまでは、React はコンポーネントをマウントして以下のように副作用を作成してきました：</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React がコンポーネントをマウント
  * レイアウト副作用 (layout effect) を作成
  * （通常の）副作用を作成</code></pre></div>
<p>React 18 の strict モードでは、開発時にコンポーネントがマウントされた場合、React はコンポーネントの即時アンマウント・再マウントをシミュレーションします：</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React がコンポーネントをマウント
    * レイアウト副作用を作成
    * 副作用を作成
* マウントされたコンポーネント内で副作用の破棄をシミュレート
    * レイアウト副作用を破棄
    * 副作用を破棄
* マウントされたコンポーネント内で以前の state を復元し副作用の再生成をシミュレート
    * レイアウト副作用を作成
    * 副作用の作成用コードの実行</code></pre></div>
<p><a href="/docs/strict-mode.html#ensuring-reusable-state">state 再利用可能性の保証についてのドキュメントはこちら</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>新たなフック </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> はハイドレーション時の不整合を防ぎつつクライアントとサーバで一意な ID を生成するためのフックです。これは主に、一意な ID を必要とするアクセシビリティ API を組み込むようなコンポーネントライブラリで有用なものです。これにより React 17 およびそれ以前から既に存在した問題が解決されますが、React 18 では新しいストリーミング対応のサーバレンダラが HTML を順番通りに送信しなくなるため、この問題はより重要です。<a href="/docs/hooks-reference.html#useid">こちらのドキュメントを参照</a>。</p>
<blockquote>
<p>補足</p>
<p><code class="gatsby-code-text">useId</code> は<a href="/docs/lists-and-keys.html#keys">リスト内の key</a> を作成するのに使うためのものでは<strong>ありません</strong>。key はあなたのデータから作成されるべきです。</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> と <code class="gatsby-code-text">startTransition</code> により、一部の更新は緊急性が低いということをマークできるようになります。その他の更新はデフォルトで緊急性が高いものとして扱われます。React は緊急性の高い更新（例えばテキスト入力の更新）が、緊急性の低い更新（例えば検索結果のリストのレンダー）を中断できるようになります。<a href="/docs/hooks-reference.html#usetransition">こちらのドキュメントを参照</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> により、ツリー内の緊急性の低い更新の再レンダーを遅延させることができます。デバウンス (debounce) に似ていますが、それと比べていくつかの利点があります。遅延時間が固定でないため、最初のレンダーが画面に反映された時点ですぐに遅延されていた方のレンダーを始められるのです。また遅延されたレンダーは中断可能であり、ユーザインプットをブロックしません。<a href="/docs/hooks-reference.html#usedeferredvalue">こちらのドキュメントを参照</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> は、外部ストアへの更新を強制的に同期的に行うことで、外部ストアが並行読み取りを行えるようにします。これにより外部のデータソースに購読する際に <code class="gatsby-code-text">useEffect</code> を使う必要性がなくなるので、React 外部の状態を扱うあらゆるライブラリにとって推奨されるものです。<a href="/docs/hooks-reference.html#usesyncexternalstore">こちらのドキュメントを参照</a>。</p>
<blockquote>
<p>補足</p>
<p><code class="gatsby-code-text">useSyncExternalStore</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> は、CSS-in-JS ライブラリがレンダー時にスタイルを注入する際のパフォーマンス上の問題に対処できるようにするための新しいフックです。すでに CSS-in-JS ライブラリを構築しているのでなければ、これを使うことはまずないでしょう。このフックは、DOM が書き換えられた後、レイアウト副作用 (layout effect) が新しいレイアウトを読み込む前に実行されます。これにより React 17 およびそれ以前から既に存在した問題が解決されますが、React 18 では並行レンダー中にブラウザに処理が渡り、そこでレイアウトが再計算される可能性があるため、より重要です。<a href="/docs/hooks-reference.html#useinsertioneffect">こちらのドキュメントを参照</a>。</p>
<blockquote>
<p>補足</p>
<p><code class="gatsby-code-text">useInsertionEffect</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>アップグレード方法 </h2>
<p>ステップバイステップのガイド、および破壊的変更・注目すべき変更の全リストについては <a href="https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html" target="_blank" rel="nofollow noopener noreferrer">React 18 アップグレードガイド</a>を参照してください。</p>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li>Add <code class="gatsby-code-text">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://ja.reactjs.org/blog/2022/03/29/react-v18.html</link><guid isPermaLink="false">https://ja.reactjs.org/blog/2022/03/29/react-v18.html</guid><pubDate>Tue, 29 Mar 2022 00:00:00 GMT</pubDate></item><item><title><![CDATA[React 18 アップグレードガイド]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p><a href="/blog/2022/03/29/react-v18.html">リリース告知の記事</a>でお伝えしたとおり、React 18 には新たな並行レンダラを用いた機能が加わっており、既存のアプリケーションが段階的に採用できる方法も提供しています。この投稿では、React 18 にアップグレードするためのステップについてご案内します。</p>
<p>React 18 にアップグレードする際に遭遇した<a href="https://github.com/facebook/react/issues/new/choose" target="_blank" rel="nofollow noopener noreferrer">問題は報告</a>をお願いします。</p>
<p><em class="em-ja">React Native ユーザ向けの注意：React 18 のリリースは React Native の将来のバージョンで行います。これは、このブログ記事で紹介する新機能を活用した新たな React Native アーキテクチャに React 18 が依存しているからです。詳細は<a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;t=1530s" target="_blank" rel="nofollow noopener noreferrer">こちらの React Conf キーノート</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>インストール </h2>
<p>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>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>クライアントレンダリング API への変更 </h2>
<p>まず React 18 をインストールすると、以下のような警告がコンソールに表示されます：</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 では複数のルートを管理する際の使い勝手を改善する、新しいルート API を導入しています。新しいルート 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">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><code class="gatsby-code-text">unmountComponentAtNode</code> も <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>またレンダー後のコールバックも削除されました。サスペンスを使った場合に、大抵は期待される結果にならないためです：</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>補足</p>
<p>以前の render のコールバック API に一対一で対応するものは存在せず、ユースケースによって対応は異なります。詳細はワーキンググループの投稿 <a href="https://github.com/reactwg/react-18/discussions/5" target="_blank" rel="nofollow noopener noreferrer">Replacing render with createRoot</a> を参照してください。</p>
</blockquote>
<p>最後に、あなたのアプリでサーバサイドレンダリングとハイドレーションを使用している場合は、<code class="gatsby-code-text">hydrate</code> を <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>詳細は<a href="https://github.com/reactwg/react-18/discussions/5" target="_blank" rel="nofollow noopener noreferrer">こちらのワーキングループのディスカッション</a>を参照してください。</p>
<blockquote>
<p>補足</p>
<p><strong>アップグレード後にアプリが動かなくなった場合は、アプリを <code class="gatsby-code-text">&lt;StrictMode></code> でラップしていないか確認してください。</strong><a href="#updates-to-strict-mode">strict モードは React 18 でより厳密になっている</a>ため、開発モードで新たに追加されたチェックにあなたのコンポーネントがすべて適合していないのかもしれません。もし strict モードを外したらアプリが動くようになった場合、アップグレード中は外したままにして、指摘された問題を修正してから元に戻す（トップにでもツリーの一部に対してでも）のでも構いません。</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>サーバレンダリング API への変更 </h2>
<p>このリリースでは、<code class="gatsby-code-text">react-dom/server</code> を刷新し、サーバ側でのサスペンスやストリーミング SSR がフルサポートされるようになりました。この変更の一環として、サーバ側での逐次的なサスペンスのストリーミング処理をサポートしない既存の Node ストリーミング API を非推奨としました。</p>
<p>以下の API を使うと警告が出るようになります：</p>
<ul>
<li><code class="gatsby-code-text">renderToNodeStream</code>: <strong>非推奨 ⛔️️</strong></li>
</ul>
<p>代わりに Node 環境でのストリーミングには以下を使ってください：</p>
<ul>
<li><code class="gatsby-code-text">renderToPipeableStream</code>: <strong>New ✨</strong></li>
</ul>
<p>また、Deno や Cloudflare Workers のようなモダンなエッジランタイム環境でサスペンス付き SSR ストリーミングをサポートする、新たな API を導入します：</p>
<ul>
<li><code class="gatsby-code-text">renderToReadableStream</code>: <strong>New ✨</strong></li>
</ul>
<p>以下の API はこれからも動作しますが、サスペンスのサポートに制限がつきます：</p>
<ul>
<li><code class="gatsby-code-text">renderToString</code>: <strong>制限付き</strong> ⚠️</li>
<li><code class="gatsby-code-text">renderToStaticMarkup</code>: <strong>制限付き</strong> ⚠️</li>
</ul>
<p>最後に、電子メールをレンダーする目的であれば以下の API を引き続き利用できます：</p>
<ul>
<li><code class="gatsby-code-text">renderToStaticNodeStream</code></li>
</ul>
<p>サーバレンダリング用 API についての詳細は、ワーキンググループの投稿 <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 href="https://github.com/reactwg/react-18/discussions/37" target="_blank" rel="nofollow noopener noreferrer">deep dive on the new Suspense SSR Architecture</a> を、また React Conf 2011 での <a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</a> の発表 <a href="https://www.youtube.com/watch?v=pj5N-Khihgc" target="_blank" rel="nofollow noopener noreferrer">Streaming Server Rendering with Suspense</a> をご覧ください。</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>TypeScript 型定義の変更 </h2>
<p>プロジェクトで TypeScript を使っている場合、依存の <code class="gatsby-code-text">@types/react</code> と <code class="gatsby-code-text">@types/react-dom</code> を最新バージョンに更新する必要があります。新たな型はより安全であり、これまで型チェッカに無視されていた問題を捕捉することができます。最も大きな変更は、props を定義する際に <code class="gatsby-code-text">children</code> プロパティを明示的に列挙する必要があるということです。例えば：</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>型にのみ関連する変更の全リストについては <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210" target="_blank" rel="nofollow noopener noreferrer">React 18 の型についてのプルリクエスト</a> を参照してください。ライブラリ型についての修正のサンプルへのリンクがあり、コードをどのように調整すればいいか分かるようになっています。<a href="https://github.com/eps1lon/types-react-codemod" target="_blank" rel="nofollow noopener noreferrer">自動移行スクリプト</a>を使うことで、あなたのアプリケーションコードをより新しく、より安全な型定義にすばやく移行しやすくなります。</p>
<p>型に関するバグを見つけた場合は、DefinitelyTyped リポジトリで <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/new?category=issues-with-a-types-package" target="_blank" rel="nofollow noopener noreferrer">issue を登録</a>してください。</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>自動バッチング </h2>
<p>React 18 はデフォルトでより多くのバッチング (batching) を行うことで、標準状態でのパフォーマンスを改善します。バッチングとは React がパフォーマンスのために複数のステート更新をグループ化して、単一の再レンダーにまとめることを指します。React 18 より前は、React のイベントハンドラ内での更新のみバッチ処理されていました。promise や setTimeout、ネイティブのイベントハンドラやその他あらゆるイベント内で起きる更新はデフォルトではバッチ処理されていませんでした。</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>React 18 以降で <code class="gatsby-code-text">createRoot</code> を使うと、すべての更新はどこで発生したかに関わらず、自動でバッチ処理されます。つまり、タイムアウト、promise、ネイティブイベントハンドラおよびその他のあらゆるイベント内で起きた更新は、React イベントで起こった更新と同様にバッチ処理されます：</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>これは破壊的変更ですが、これによりレンダー処理が軽くなり、したがってアプリのパフォーマンスが向上することが期待されます。自動バッチングからオプトアウトするために <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>詳細については、<a href="https://github.com/reactwg/react-18/discussions/21" target="_blank" rel="nofollow noopener noreferrer">Automatic batching 詳解</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>ライブラリ向けの新 API </h2>
<p>React 18 ワーキンググループでライブラリメンテナと共同で作業を行い、スタイルや外部ストアといった分野に特有のユースケースで並行レンダー機能をサポートするため、新しい API を作成しました。一部のライブラリは、React 18 をサポートするために以下の API に切り替える必要があるかもしれません：</p>
<ul>
<li><code class="gatsby-code-text">useSyncExternalStore</code> は、ストアへの更新を強制的に同期的に行うことで、並行読み取りを外部ストアがサポートできるようにするための新たなフックです。この新しい API は React 外部の状態を扱うあらゆるライブラリにとって推奨されるものです。詳細は <a href="https://github.com/reactwg/react-18/discussions/70" target="_blank" rel="nofollow noopener noreferrer">useSyncExternalStore 概要</a>および <a href="https://github.com/reactwg/react-18/discussions/86" target="_blank" rel="nofollow noopener noreferrer">useSyncExternalStore API 詳細</a>を参照してください。</li>
<li><code class="gatsby-code-text">useInsertionEffect</code> は、CSS-in-JS ライブラリがレンダー時にスタイルを注入する際のパフォーマンス上の問題に対処できるようにするための新しいフックです。すでに CSS-in-JS ライブラリを構築しているのでなければ、これを使うことはまずないでしょう。このフックは、DOM が書き換えられた後、レイアウト副作用 (layout effect) が新しいレイアウトを読み込む前に実行されます。これにより React 17 およびそれ以前から既に存在した問題が解決されますが、React 18 では並行レンダー中にブラウザに処理が渡り、そこでレイアウトが再計算される可能性があるため、より重要です。詳細は <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 では <code class="gatsby-code-text">startTransition</code>、<code class="gatsby-code-text">useDeferredValue</code> や <code class="gatsby-code-text">useId</code> のような新しい API も導入しており、<a href="/blog/2022/03/29/react-v18.html">リリース告知記事</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>strict モードへの変更 </h2>
<p>将来的に、React が state を保ったままで UI の一部分を追加・削除できるような機能を導入したいと考えています。例えば、ユーザがタブを切り替えて画面を離れてから戻ってきた場合に、React が以前の画面をすぐに表示できるようにしたいのです。これを可能にするため、React は同じ state を使用してツリーをアンマウント・再マウントします。</p>
<p>この機能により、React の標準状態でのパフォーマンスが向上しますが、コンポーネントは副作用が何度も登録されたり破棄されたりすることに対して耐性を持つことが必要になります。ほとんどの副作用は何の変更もなく動作しますが、一部の副作用は一度しか登録・破棄されないものと想定しています。</p>
<p>この問題に気付きやすくするために、React 18 は strict モードに新しい開発時専用のチェックを導入します。この新しいチェックは、コンポーネントが初めてマウントされるたびに、すべてのコンポーネントを自動的にアンマウント・再マウントし、かつ 2 回目のマウントで以前の state を復元します。</p>
<p>これまでは、React はコンポーネントをマウントして以下のように副作用を作成してきました：</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React がコンポーネントをマウント
  * レイアウト副作用 (layout effect) を作成
  * （通常の）副作用を作成</code></pre></div>
<p>React 18 の strict モードでは、開発時にコンポーネントがマウントされた場合、React はコンポーネントの即時アンマウント・再マウントをシミュレーションします：</p>
<div class="gatsby-highlight" data-language="text"><pre class="gatsby-code-text"><code class="gatsby-code-text">* React がコンポーネントをマウント
    * レイアウト副作用を作成
    * 副作用を作成
* マウントされたコンポーネント内で副作用の破棄をシミュレート
    * レイアウト副作用を破棄
    * 副作用を破棄
* マウントされたコンポーネント内で以前の state を復元し副作用の再生成をシミュレート
    * レイアウト副作用を作成
    * 副作用の作成用コードの実行</code></pre></div>
<p>詳細については、ワーキンググループの投稿 <a href="https://github.com/reactwg/react-18/discussions/19" target="_blank" rel="nofollow noopener noreferrer">Adding Reusable State to StrictMode</a> と <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>テスト環境の設定 </h2>
<p>まずテストで <code class="gatsby-code-text">createRoot</code> を使うようにアップデートした場合、テストコンソールに以下の警告が表示されます：</p>
<blockquote>
<p>The current testing environment is not configured to support act(…)</p>
</blockquote>
<p>これを修正するには、テスト実行前に <code class="gatsby-code-text">globalThis.IS_REACT_ACT_ENVIRONMENT</code> を <code class="gatsby-code-text">true</code> に設定します：</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>このフラグの目的は、React がユニットテスト的な環境で実行されている、と React に伝えることです。React は更新を <code class="gatsby-code-text">act</code> でラップし忘れた場合に、有用な警告を表示するようになります。</p>
<p>このフラグを <code class="gatsby-code-text">false</code> に設定することで <code class="gatsby-code-text">act</code> が必要ないと React に伝えることもできます。これはフル機能のブラウザ環境をシミュレートする end-to-end テストにおいて有用です。</p>
<p>将来的には、テストライブラリがこれを自動で設定するようになることを期待しています。例えば <a href="https://github.com/testing-library/react-testing-library/issues/509#issuecomment-917989936" target="_blank" rel="nofollow noopener noreferrer">React Testing Library の次期バージョンは React 18 の組み込みサポートを有しており</a>、追加の設定が不要となっています。</p>
<p>ワーキングループで<a href="https://github.com/reactwg/react-18/discussions/102" target="_blank" rel="nofollow noopener noreferrer">テスト用 <code class="gatsby-code-text">act</code> API および関連する変更に関しての背景</a>が閲覧可能です。</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>Internet Explorer のサポート終了 </h2>
<p>このリリースで、React は <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">2022 年 6 月 15 日にサポート外</a> となる Internet Explorer のサポートを終了します。この変更を今行うのは、React 18 で導入される新機能はマイクロタスクのようなモダンなブラウザの機能を使っており、IE でうまくポリフィルできないからです。</p>
<p>Internet Explorer のサポートが必要な場合は、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>非推奨化 </h2>
<ul>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.render</code> は非推奨となりました。使うと警告が表示され、アプリは React 17 モードで動作します。</li>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.hydrate</code> は非推奨となりました。使うと警告が表示され、アプリは React 17 モードで動作します。</li>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.unmountComponentAtNode</code> は非推奨となりました。</li>
<li><code class="gatsby-code-text">react-dom</code>: <code class="gatsby-code-text">ReactDOM.renderSubtreeIntoContainer</code> は非推奨となりました。</li>
<li><code class="gatsby-code-text">react-dom/server</code>: <code class="gatsby-code-text">ReactDOMServer.renderToNodeStream</code> は非推奨となりました。</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>その他の破壊的変更 </h2>
<ul>
<li><strong>useEffect のタイミング統一</strong>：React はクリックやキー押下のような個別のユーザ入力によって更新がトリガされた場合に副作用関数を常に同期的に処理するようになりました。これまで、この挙動は必ずしも予測可能な一貫したものではありませんでした。</li>
<li><strong>ハイドレーション時のエラーの厳格化</strong>：テキストコンテンツが存在しない、あるいは余分に存在することによるハイドレーションのミスマッチは、警告ではなくエラーとして扱われるようになりました。今後 React はサーバのマークアップに適合させるために個別のノードをクライアント側で挿入したり削除したりといった「応急処置」を試みないようになるため、ツリー内の直近の <code class="gatsby-code-text">&lt;Suspense></code> バウンダリまでクライアント側のレンダーを使うための逆戻りが発生してしまいます。この変更により、ハイドレーションされたツリーに一貫性があることが保証され、ハイドレーション時のミスマッチにより起こりうる個人情報やセキュリティ絡みの問題を防止できます。</li>
<li><strong>サスペンス内のツリーが常に一貫性のあるものに</strong>：コンポーネントがツリーに完全に追加される前にサスペンドした場合、React はそれを不完全な状態のままツリーに追加したり、副作用を起動したりはしません。その代わり、React は新しいツリーを完全に破棄し、非同期の操作が完了するのを待ち、最初からレンダーを再試行します。React は再試行を、並行的に、ブラウザをブロックせずに行います。</li>
<li><strong>サスペンスとレイアウト副作用</strong>：ツリーが再サスペンドしてフォールバックに逆戻りする場合、React はレイアウト用の副作用をクリーンアップし、バウンダリ内のコンテンツが再表示されるときにそれらを再作成するようになりました。これにより、サスペンスと一緒に使用されたときにコンポーネントライブラリがレイアウトを正しく測定できないという問題が修正されます。</li>
<li><strong>JS 環境の要件変更</strong>：React は <code class="gatsby-code-text">Promise</code>、<code class="gatsby-code-text">Symbol</code>、<code class="gatsby-code-text">Object.assign</code> のようなモダンブラウザの機能に依存するようになりました。モダンなブラウザ機能についてネイティブ実装していないか非標準な実装をしている Internet Explorer のような古いブラウザやデバイスをサポートする場合は、バンドルされたアプリにグローバルなポリフィルを含めることを検討してください。</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>その他の注目すべき変更 </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>コンポーネントが <code class="gatsby-code-text">undefined</code> を return できるように</strong>：React はコンポーネントから <code class="gatsby-code-text">undefined</code> が返された場合でも警告しなくなりました。これにより、コンポーネントからの返り値として許される値が、コンポーネントツリーの中間で許可される値と合致するようになりました。JSX の前に <code class="gatsby-code-text">return</code> 文を書き忘れるといったミスを防ぐためには、リンタを使用することをお勧めします。</li>
<li><strong>テストにおいて <code class="gatsby-code-text">act</code> 警告がオプトインに</strong>：End-to-end のテストを実行している場合、<code class="gatsby-code-text">act</code> 警告は不要です。<a href="https://github.com/reactwg/react-18/discussions/102" target="_blank" rel="nofollow noopener noreferrer">オプトインする</a>メカニズムを用意しましたので、それが有用であるユニットテストの場合にのみ有効化できるようになりました。</li>
<li><strong>アンマウント済みコンポーネントにおける <code class="gatsby-code-text">setState</code> で警告を表示しないように</strong>：これまで React は、<code class="gatsby-code-text">setState</code> がアンマウント済みのコンポーネントでコールされた場合、メモリリークに関する警告を表示してきました。この警告は購読に関する問題のために存在していましたが、state をセットしても問題ないシナリオでもこの警告にぶつかることが多く、また回避しようとした場合余計に悪いコードになってしまっていました。この警告は<a href="https://github.com/facebook/react/pull/22114" target="_blank" rel="nofollow noopener noreferrer">削除</a>されました。</li>
<li><strong>コンソールログの抑止を廃止</strong>：strict モードを利用する場合、React はコンポーネントを 2 回レンダーして、予期しない副作用がないか見つけやすくします。React 17 では、ログが見やすくなるようにそのうちの 1 回ではコンソールログを抑止するようにしていました。これが混乱を招くという<a href="https://github.com/facebook/react/issues/21783" target="_blank" rel="nofollow noopener noreferrer">コミュニティからのフィードバック</a>を受けて、このような抑止を行うことを止めました。代わりに、React DevTools をインストールしている場合は、2 回目のレンダーでのログはグレーで表示されるようになりました。完全に抑止するためのオプション（デフォルトではオフ）も存在します。</li>
<li><strong>メモリ使用量の改善</strong>：React はアンマウント時に内部のフィールドをより多く消去するようになったため、あなたのアプリに未修正のメモリリークがあった場合の悪影響が軽減されます。</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>：サーバ側でサスペンドが起きた場合でもエラーにならなくなりました。代わりに、直近の <code class="gatsby-code-text">&lt;Suspense></code> にあるフォールバック HTML を出力し、クライアント側で同じコンテンツのレンダーを再試行するようになります。とはいえ、<code class="gatsby-code-text">renderToPipeableStream</code> や <code class="gatsby-code-text">renderToReadableStream</code> のようなストリーミング API に切り替えることが推奨されます。</li>
<li><strong><code class="gatsby-code-text">renderToStaticMarkup</code></strong>：サーバ側でサスペンドが起きた場合でもエラーにならなくなりました。代わりに、直近の <code class="gatsby-code-text">&lt;Suspense></code> にあるフォールバック HTML を出力します。</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><a href="https://github.com/facebook/react/blob/main/CHANGELOG.md" target="_blank" rel="nofollow noopener noreferrer">変更履歴の全リストはこちら</a>を参照してください。</p>]]></description><link>https://ja.reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html</link><guid isPermaLink="false">https://ja.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 振り返り]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p>先週、第 6 回の React Conf を開催しました。これまでの年度において、我々は React Conf のステージ上で、<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> や <a href="https://reactjs.org/docs/hooks-intro.html" target="_blank" rel="nofollow noopener noreferrer"><em>React Hooks</em></a> といった業界を変えるような発表をお届けしてきました。本年度は、React 18 のリリースと並行レンダリング機能の段階的な採用から始まる我々のマルチプラットフォーム戦略についての話題を共有しました。</p>
<p>React Conf がオンラインで開催されたのは今回が初めてですが、イベントは 8 つの言語に翻訳され、無料でストリーミング配信されました。世界中の参加者が、カンファレンスの Discord や、すべてのタイムゾーンの方がアクセスしやすいように行われたリプレイイベントに参加しました。登録者数は 50,000 人以上に達し、19 の演題は 60,000 回以上閲覧され、両イベントを通じて Discord には 5,000 人の参加者が集まりました。</p>
<p>すべての発表は<a href="https://www.youtube.com/watch?v=FZ0cG47msEk&#x26;list=PLNG_1j3cPCaZZ7etkzWA7JfdmKWT0pMsa" target="_blank" rel="nofollow noopener noreferrer">オンラインストリーミングで閲覧可能です</a>。</p>
<p>以下が、ステージ上で共有された内容のおさらいとなります。</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 と並行レンダリング機能 </h2>
<p>キーノートでは、React 18 から始まる React の将来のビジョンについて共有しました。</p>
<p>React 18 には、長らく待望されてきた並行レンダラと、サスペンスへの機能追加が、大きな破壊的変更なしに入ります。アプリは、他のメジャーリリースのときと変わらない程度の労力で React 18 にアップグレードして、並行レンダリングの機能を段階的に採用していくことが可能です。</p>
<p><strong>これはつまり、並行モードというものがなくなった、ということです。並列レンダリング機能のみが存在します。</strong></p>
<p>キーノートではさらに、サスペンス、サーバコンポーネント、新たな React ワーキンググループ、そして React Native の長期的な多プラットフォーム戦略についてお話ししました。</p>
<p><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>、<a href="https://twitter.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">Rick Hanlon</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/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 </h2>
<p>キーノートでは、React 18 RC が評価のために今すぐ利用可能であることを発表しました。さらなるフィードバックを待ちつつも、これが来年初頭に我々が安定版として公開する予定の React のバージョンそのものとなります。</p>
<p>React 18 RC を試すには、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>そして新しい <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>React 18 へのアップグレードのデモについては、<a href="https://twitter.com/shrutikapoor08" target="_blank" rel="nofollow noopener noreferrer">Shruti Kapoor</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/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>サスペンスを使ったストリーミングサーバレンダリング </h2>
<p>React 18 にはサスペンスを使ったサーバサイドレンダリングのパフォーマンス改善が含まれています。</p>
<p>ストリーミングサーバレンダリングによって、サーバ側で React コンポーネントから HTML を作成し、それをユーザにストリームで送ることができます。React 18 では、<code class="gatsby-code-text">Suspense</code> を使ってアプリを小さな単位に分割し、それぞれがアプリの他の部分をブロックせずに独立してストリーミング処理できるようになります。これによりユーザはより早くコンテンツを見ることができ、素早くインタラクションができるようになる、ということです。</p>
<p>詳しくは、<a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</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/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>React ワーキンググループの立ち上げ </h2>
<p>React 18 では、エキスパートや開発者、ライブラリメンテナ、教育者のグループと協力して作業するため、初めてワーキンググループを立ち上げました。彼らとともに、段階的な採用戦略を作成し、<code class="gatsby-code-text">useId</code>、<code class="gatsby-code-text">useSyncExternalStore</code>, <code class="gatsby-code-text">useInsertionEffect</code> といった API の改善を行ってきました。</p>
<p>この試みの概要については、<a href="https://twitter.com/aakansha1216" target="_blank" rel="nofollow noopener noreferrer">Aakansha’ Doshi</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/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 の開発者向けツーリング </h2>
<p>このリリースにおける新機能をサポートするため、新たに構成された React DevTools チームと、開発者が React アプリをデバッグしやすくするための新たなタイムラインプロファイラについて発表しました。</p>
<p>新たな DevTools の機能についての詳細およびデモについては、<a href="https://twitter.com/brian_d_vaughn" target="_blank" rel="nofollow noopener noreferrer">Brian Vaughn</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/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>memo 不要の React </h2>
<p>より将来に目を向けた話として、<a href="https://twitter.com/Huxpro" target="_blank" rel="nofollow noopener noreferrer">Xuan Huang (黄玄)</a> は、React Labs が行っている自動メモ化コンパイラに関する研究の現状についてお話ししました。この発表とコンパイラのプロタイプについての詳細・デモは以下でご覧ください：</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 ドキュメントキーノート </h2>
<p>React の学習や React による設計についての一連の発表は <a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a> からスタートしました。その中では React の <a href="https://react.dev/" target="_blank" rel="nofollow noopener noreferrer">新ドキュメント</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>さらに… </h1>
<p><strong>React の学習や 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>Relay、React Native、PyTorch チームからの発表：</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>アクセシビリティ、ツーリング、サーバコンポーネントについてコミュニティからの発表：</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>謝辞 </h1>
<p>我々自身でカンファレンスを計画したのは今年が初めてでした。多くの方に感謝したいと思います。</p>
<p>まずは発表者の方々に感謝します。<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>、<a href="https://twitter.com/Huxpro" target="_blank" rel="nofollow noopener noreferrer">Xuan Huang (黄玄)</a>。</p>
<p>発表についてのフィードバックを頂いた方々に感謝します。<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>、<a href="https://twitter.com/yungsters" target="_blank" rel="nofollow noopener noreferrer">Tim Yung</a>。</p>
<p>カンファレンス Discord のセットアップを行い Discord 管理者になっていただいた <a href="https://twitter.com/potetotes" target="_blank" rel="nofollow noopener noreferrer">Lauren Tan</a> に感謝します。</p>
<p>全体の方向性や、多様性とその受け入れについて助言をいただいた <a href="https://twitter.com/sethwebster" target="_blank" rel="nofollow noopener noreferrer">Seth Webster</a> に感謝します。</p>
<p>モデレーション関係業務の先頭に立っていただいた <a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a>、そしてモデレーションガイドを作成し、モデレーションチームを率い、翻訳者とモデレータの教育を行い、両イベントのモデレーションに協力していただいた <a href="https://twitter.com/AishaBlake" target="_blank" rel="nofollow noopener noreferrer">Aisha Blake</a> に感謝します。</p>
<p>モデレータの方々に感謝します。<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、<a href="https://twitter.com/Huxpro" target="_blank" rel="nofollow noopener noreferrer">Xuan Huang (黄玄)</a>.</p>
<p>リプレイイベントのモデレーションやコミュニティへの活動に協力頂いた、<a href="https://www.reactindia.io/" target="_blank" rel="nofollow noopener noreferrer">React India</a> の <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>、Vihang Patel、および <a href="https://twitter.com/ReactChina" target="_blank" rel="nofollow noopener noreferrer">React China</a> の <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>、<a href="https://twitter.com/anneincoding" target="_blank" rel="nofollow noopener noreferrer">YanLun Li</a> に感謝します。</p>
<p>カンファレンスのウェブサイトを構築するのに使った <a href="https://vercel.com/virtual-event-starter-kit" target="_blank" rel="nofollow noopener noreferrer">Virtual Event Starter Kit</a> を公開していただいた Vercel、そして Next.js Conf での経験を共有していただいた <a href="https://twitter.com/leeerob" target="_blank" rel="nofollow noopener noreferrer">Lee Robinson</a> と <a href="https://twitter.com/delba_oliveira" target="_blank" rel="nofollow noopener noreferrer">Delba de Oliveira</a> に感謝します。</p>
<p>カンファレンス運営の経験や <a href="https://rustconf.com/" target="_blank" rel="nofollow noopener noreferrer">RustConf</a> 運営からの教訓を共有していただいた <a href="https://twitter.com/wifelette" target="_blank" rel="nofollow noopener noreferrer">Leah Silber</a> に感謝します。彼女の書籍 <a href="https://leanpub.com/eventdriven/" target="_blank" rel="nofollow noopener noreferrer">Event Driven</a> とそこに含まれたカンファレンス運営に関する助言に感謝します。</p>
<p>Women of React Conf の運営経験について共有していただいた <a href="https://twitter.com/_phzn" target="_blank" rel="nofollow noopener noreferrer">Kevin Lewis</a> と <a href="https://twitter.com/rachelnabors" target="_blank" rel="nofollow noopener noreferrer">Rachel Nabors</a> に感謝します。</p>
<p>企画全体にわたってアドバイスやアイディアをいただいた <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>、<a href="https://twitter.com/shaundai" target="_blank" rel="nofollow noopener noreferrer">Shaundai Person</a> に感謝します。</p>
<p>カンファレンスウェブサイトとチケットのデザイン・構築に協力いただいた <a href="https://twitter.com/lebo" target="_blank" rel="nofollow noopener noreferrer">Dan Lebowitz</a> に感謝します。</p>
<p>キーノートや Meta 従業員の発表の録画をしていただいた Laura Podolak Waddell、Desmond Osei-Acheampong、Mark Rossi、Josh Toberman および Facebook Video Productions の他の方々に感謝します。</p>
<p>カンファレンスの運営、ストリームされる全ビデオの編集、全発表の翻訳、そして多言語での Discord のモデレーションについて協力いただいたパートナーの HitPlay に感謝します。</p>
<p>最後に、この React Conf を素晴らしいものにしていただいたすべての参加者の皆さんに感謝します！</p>]]></description><link>https://ja.reactjs.org/blog/2021/12/17/react-conf-2021-recap.html</link><guid isPermaLink="false">https://ja.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[React 18に向けてのプラン]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<blockquote>
<p>2021 年 11 月 15 日追記：</p>
<p>React 18 はベータ版となりました。リリースに関する最新情報は <a href="https://github.com/reactwg/react-18/discussions/112" target="_blank" rel="nofollow noopener noreferrer">React 18 ワーキンググループの投稿で確認できます</a>。</p>
</blockquote>
<p>React チームより幾つかのお知らせがあります！</p>
<ol>
<li>次のメジャーバージョンとなる React 18 リリースに向けての作業を開始しました。</li>
<li>コミュニティが React 18 の新機能を段階的に導入できるようにするため、ワーキンググループを作成しました。</li>
<li>ライブラリの作者が試用してフィードバックを送れるようにするため、React 18 のアルファ版を公開しました。</li>
</ol>
<p>これらのお知らせは、主にサードパーティのライブラリメンテナ向けです。ユーザ向けのアプリケーションを作成するために React を学んでいる、教えている、あるいは利用している方は、この投稿を無視していただいて問題ありません。もちろん興味があれば React 18 ワーキンググループでの議論をフォローすることは歓迎です！</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>React 18 の新機能 </h2>
<p>React 18 のリリース時点で、自動で有効になるパフォーマンス改善（例：<a href="https://github.com/reactwg/react-18/discussions/21" target="_blank" rel="nofollow noopener noreferrer">自動バッチング</a>）、新たな API（例：<a href="https://github.com/reactwg/react-18/discussions/41" target="_blank" rel="nofollow noopener noreferrer"><code class="gatsby-code-text">startTransition</code></a>）、そして <code class="gatsby-code-text">React.lazy</code> の組み込みサポートを有する<a href="https://github.com/reactwg/react-18/discussions/37" target="_blank" rel="nofollow noopener noreferrer">新しいストリーミングサーバレンダラ</a>が含まれています。</p>
<p>これらは、React 18 で我々が追加しようとしている新たなオプトインのメカニズムのおかげで実現可能になるものです。そのメカニズムとは「並行レンダリング」であり、これにより React は、UI の複数のバージョンを同時に用意しておくことができるようになります。これはほとんどの場面では裏で勝手に行われますが、あなたのアプリの実パフォーマンスおよび体感上のパフォーマンスを向上させる可能性を秘めています。</p>
<p>我々が React の未来に向けて行ってきた様々なリサーチをフォローしてきた方であれば（そうすべきと言っている訳ではないですよ）、“Concurrent Mode” なる言葉を聞いたこと、あるいはそれのせいであなたのアプリが動かなくなるかもしれないということを聞いたことがあるかもしれません。これに関してのコミュニティのフィードバックを受けて、我々は段階的な導入に向けてのアップグレード戦略を再設計しました。イチかゼロかの「モード」の代わりに、並行レンダリングは新機能のどれかを利用するような更新がある場合にのみ有効化されるようになりました。実用上、これはつまり<strong>書き換えをせずに React 18 を導入し、自分のペースで React 18 の新機能を試していけるようになる</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>段階的な導入戦略 </h2>
<p>React 18 における並行レンダリングはオプトインになるため、コンポーネントの振る舞いにおいてデフォルトで大きな破壊的変更があるということはなくなります。<strong>いつものメジャーリリースのときに要する労力と大差ないレベルの最小限の書き換えで、あるいは書き換えゼロで、React 18 にアップグレードすることができます</strong>。我々がいくつかのアプリを React 18 に移植した経験から、多くのユーザは半日以内にアップグレード作業を完了できるだろうと考えています。</p>
<p>Facebook 内では既に数万のコンポーネントを並行レンダリングの機能を用いてリリースすることができました。我々の経験ではほとんどの React コンポーネントは追加の開発なしで「ごく普通に」動作することが分かっています。しかしコミュニティ全体で今回のアップグレードが確実にスムースに行くようにしたいと考えており、そのために本日、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>コミュニティとの共同作業 </h2>
<p>このリリースで、私たちは新たな試みをしようとしています。React コミュニティ全体から、少数のエキスパート、開発者、ライブラリ作者、教育関係者を <a href="https://github.com/reactwg/react-18" target="_blank" rel="nofollow noopener noreferrer">React 18 ワーキンググループ</a>に招待して、フィードバックをもらったり、質問をもらったり、リリースに向けての共同作業を行ってもらったりしているのです。初期は小さなグループであり、メンバーとして我々が望む全員を招待することはできませんでしたが、この試みがうまくいけば、将来的により多くの人を招待できると考えています！</p>
<p>React 18 ワーキンググループの目的は、既存のアプリケーションやライブラリが React 18 をスムースかつ段階的に採用できるように、エコシステムを整えることです。ワーキングループは <a href="https://github.com/reactwg/react-18/discussions" target="_blank" rel="nofollow noopener noreferrer">GitHub Discussions</a> でホストされており、誰でも読めるようになっています。ワーキンググループのメンバーのみがフィードバックを送ったり、質問したり、アイディアを共有したりできるようになっています。このディスカッション用のリポジトリは、コアチームのメンバーも研究の成果を共有するために使用します。安定リリースが近づけば、あらゆる重要な情報はこのブログにも投稿されます。</p>
<p>React 18 へのアップグレードに関する詳細やリリースに関するその他の情報については、<a href="https://github.com/reactwg/react-18/discussions/4" target="_blank" rel="nofollow noopener noreferrer">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>ワーキンググループへのアクセス方法 </h2>
<p><a href="https://github.com/reactwg/react-18" target="_blank" rel="nofollow noopener noreferrer">React 18 ワーキンググループのリポジトリ</a>でのディスカッションは、誰でも閲覧可能です。</p>
<p>当初はワーキンググループ内部で一気に興味が高まることが予想されますので、招待されたメンバーのみがスレッドを作成したりコメントしたりできるようになっています。しかしスレッドは誰でも見えるようになっていますので、全員が同じ情報にアクセスできます。ワーキンググループのメンバーにとって生産的な環境を整えつつ、より広いコミュニティへの透明性も確保するという意味で、これが良い落とし所だと考えています。</p>
<p>もちろんこれまで通り、バグレポートや質問や一般的なフィードバックについては誰でも<a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">イシュートラッカ</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>React 18 アルファ版を今すぐ試す </h2>
<p>新しいアルファ版は <a href="https://github.com/reactwg/react-18/discussions/9" target="_blank" rel="nofollow noopener noreferrer">npm に <code class="gatsby-code-text">@alpha</code> タグ付きで定期的に公開</a>されます。これらのリリースは我々のメインリポジトリにある最新のコミットを使ってビルドされます。新しい機能やバグ修正がマージされた場合、次の平日にはアルファ版で利用可能になります。</p>
<p>アルファ版同士の間では動作や API について大きな変更が加わる可能性があります。<strong>ユーザが利用する本番用アプリケーションではアルファ版は推奨されない</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>React 18 リリースタイミングの見通し </h2>
<p>具体的に予定されたリリース日時はまだありませんが、React 18 が本番アプリケーションで使えるようになるまでに、フィードバックを受けて改善を繰り返す期間が数か月ほど必要だろうと考えています。</p>
<ul>
<li>ライブラリ作者向けのアルファ：本日より利用可能</li>
<li>公開ベータ：少なくとも数か月後</li>
<li>リリース候補 (RC)：ベータから少なくとも数週間後</li>
<li>一般向けリリース：RC から少なくとも数週間後</li>
</ul>
<p>リリースタイミングの見通しについての更なる詳細は<a href="https://github.com/reactwg/react-18/discussions/9" target="_blank" rel="nofollow noopener noreferrer">ワーキンググループ内の投稿</a>で見ることができます。公開リリースが近づいたらこのブログでも情報をお伝えします。</p>]]></description><link>https://ja.reactjs.org/blog/2021/06/08/the-plan-for-react-18.html</link><guid isPermaLink="false">https://ja.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[バンドルサイズゼロの React Server Components の紹介]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p>2020 年は長い 1 年でした。本年の最後に、我々の研究における特別なホリデーアップデートとして、バンドルサイズゼロで動作する <strong>React サーバコンポーネント</strong>の紹介をしたいと思います。</p>
<p>サーバコンポーネントの紹介のためのトークとデモを用意しました。休暇期間中にチェックするもよし、来年仕事に戻ってきた時に見てみるのでもよいでしょう。</p>
<br>
<div class="gatsby-resp-iframe-wrapper" style="padding-bottom: 56.25%; position: relative; height: 0; overflow: hidden; " > <iframe src="https://www.youtube.com/embed/TQQPAU21ZUw" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" style=" position: absolute; top: 0; left: 0; width: 100%; height: 100%; "></iframe> </div>
<p><strong>React サーバコンポーネントは現在も研究開発中です。</strong>開発の透明性を高め、React コミュニティから初期のフィードバックを頂くために共有しています。そのための時間はまだまだありますので、<strong>今すぐ追いつく必要はありません</strong>！</p>
<p>もし気になったなら以下の順番で見ていくのをお勧めします。</p>
<ol>
<li><strong>トークを見て</strong> React サーバコンポーネントについて学び、デモを見る</li>
<li><strong><a href="http://github.com/reactjs/server-components-demo" target="_blank" rel="nofollow noopener noreferrer">デモをクローン</a></strong>して自分のコンピュータ上で React サーバコンポーネントで遊んでみる</li>
<li>技術的に深い部分について <strong><a href="https://github.com/reactjs/rfcs/pull/188" target="_blank" rel="nofollow noopener noreferrer">RFC を読み（FAQ も最後にあります）</a></strong>、フィードバックを送る</li>
</ol>
<p>RFC や Twitter の <a href="https://twitter.com/reactjs" target="_blank" rel="nofollow noopener noreferrer">@reactjs</a> へのリプライで、皆さんの意見を聞けるのを楽しみにしています。それでは良い休暇を！ また来年お元気でお会いしましょう！</p>]]></description><link>https://ja.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html</link><guid isPermaLink="false">https://ja.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>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p>本日、React 17 をリリースします！ React 17 リリースの役割や含まれている変更点については <a href="/blog/2020/08/10/react-v17-rc.html">React 17 RC のブログ記事</a>で詳しく述べてあります。この記事はそちらの短いサマリとなりますので、RC の記事を既に読んでいる場合は、本記事は飛ばして構いません。</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>新機能 “なし” </h2>
<p>この React 17 リリースは普段のリリースと異なっており、開発者向けの新機能が何も追加されていません。代わりに、このリリースは <strong>React 自体のアップグレードを簡単にすること</strong>に焦点を当てています。</p>
<p>具体的には React 17 は、あるバージョンの React で管理されるツリー内に、別のバージョンの React で管理されるツリーをより安全に埋め込めるようにするための、「踏み台」となるリリースとなっています。</p>
<p>また、他のテクノロジによって構築されているアプリ内に 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>段階的なアップグレード </h2>
<p><strong>React 17 は段階的な React のアップグレードを可能にします。</strong>React 15 から 16 に（そして今回は React 16 から 17 に）アップグレードする場合、普通はアプリ全体をまとめてアップグレードします。これは多くのアプリではうまく行きます。しかしコードが数年以上前に書かれており活発にメンテされていないような場合、だんだんと難易度が増していきます。ページ内で 2 つの React のバージョンを混在させることは可能ですが、React 17 以前にこのようなことをすると不安定になり、イベント絡みの問題が引き起こされていました。</p>
<p>React 17 で、これらの問題の多くを修正します。これは <strong>React 18 やもっと将来のバージョンが来たときに、とれる選択肢が増える</strong>ということを意味します。選択肢のひとつは、これまでやってきたのと同様、アプリ全体を一度にアップグレードするというものです。しかし今後は、アプリを一部分ずつアップグレードするという選択肢がとれるようになります。例えば、アプリの大部分を React 18 に移行しつつ、いくつかの遅延ロードされるダイアログやサブページを React 17 のままにしておけるようになります。</p>
<p>だからといって段階的に更新<em class="em-ja">しないといけない</em>という訳ではありません。<strong>今後もほとんどのアプリでは、一気にアップグレードするのがベストの選択肢です。</strong>2 つのバージョンの React をロードするというのは、たとえ片方はオンデマンドで遅延ロードするのだとしても、やはり理想的ではありません。しかし、活発にメンテされていない大きなアプリではこの選択肢は検討に値するものであり、React 17 はこのようなアプリが取り残されずに済むようにします。</p>
<p>古いバージョンの React を必要に応じて遅延ロードするという手法をデモするための<a href="https://github.com/reactjs/react-gradual-upgrade-demo/" target="_blank" rel="nofollow noopener noreferrer">サンプルリポジトリ</a>を用意しました。このデモは Create React App を使っていますが、他のどのようなツールでも似たアプローチが可能なはずです。他のツールを使ったデモを追加するプルリクエストを歓迎します。</p>
<blockquote>
<p>補足</p>
<p>その他の変更は React 17 より後に<strong>延期しました</strong>。このリリースの目標は段階的なアップグレードを可能にすることです。React 17 自体へのアップグレードが難しいようでは本リリースの目的が台無しですので、そのようなことはないはずです。</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>イベントデリゲーションに関する変更 </h2>
<p>段階的なアップグレードを可能にするために、React のイベントシステムに幾つかの変更を加える必要がありました。React 17 がメジャーリリースとなっているのは、これらの変更が一部互換性の問題を引き起こす可能性があるからです。我々の安定性に対する取り組みについては<a href="/docs/faq-versioning.html#breaking-changes">バージョニングについての FAQ</a> で読むことができます。</p>
<p>React 17 では、React は裏で <code class="gatsby-code-text">document</code> のレベルにイベントハンドラをアタッチしないようになります。代わりに、あなたが React ツリーをレンダーしようとしているルート DOM コンテナに対してアタッチするようになります：</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>React 16 およびそれ以前では、React はほとんどのイベントに対して <code class="gatsby-code-text">document.addEventListener()</code> のようにしていました。代わりに React 17 は、水面下で <code class="gatsby-code-text">rootNode.addEventListener()</code> という呼び出しを行うようになります。</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="React 17 ではイベントハンドラをドキュメントではなくルート要素にアタッチしていることを示す図"
        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>この新しい挙動により、React コードと非 React コードの統合に関して <a href="https://github.com/facebook/react/issues/7094" target="_blank" rel="nofollow noopener noreferrer">過去</a> <a href="https://github.com/facebook/react/issues/8693" target="_blank" rel="nofollow noopener noreferrer">数年に</a> <a href="https://github.com/facebook/react/issues/12518" target="_blank" rel="nofollow noopener noreferrer">わたって</a> <a href="https://github.com/facebook/react/issues/13451" target="_blank" rel="nofollow noopener noreferrer">報告</a> <a href="https://github.com/facebook/react/issues/4335" target="_blank" rel="nofollow noopener noreferrer">されて</a> <a href="https://github.com/facebook/react/issues/1691" target="_blank" rel="nofollow noopener noreferrer">きた</a> <a href="https://github.com/facebook/react/issues/285#issuecomment-253502585" target="_blank" rel="nofollow noopener noreferrer">様々な</a> <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">問題が</a> <a href="https://github.com/facebook/react/issues/11530" target="_blank" rel="nofollow noopener noreferrer">解決</a> <a href="https://github.com/facebook/react/issues/7128" target="_blank" rel="nofollow noopener noreferrer">される</a> ことが分かっています。</p>
<p>この変更により問題が出た場合は、<a href="/blog/2020/08/10/react-v17-rc.html#fixing-potential-issues">こちらによくある解決法が載っています</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>その他の破壊的変更 </h2>
<p><a href="/blog/2020/08/10/react-v17-rc.html#other-breaking-changes">React 17 RC のブログ記事</a> に React 17 におけるその他の破壊的変更について説明があります。</p>
<p>Facebook のプロダクトコードにおける 10 万を超えるのコンポーネントのうち、これらの変更に対応するために変更する必要があったのは 20 未満でしたので、<strong>ほとんどのアプリは React 17 にトラブルなく移行できると考えています</strong>。問題があった場合は<a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">知らせてください</a>。</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>新しい JSX トランスフォーム </h2>
<p>Raect 17 は<a href="/blog/2020/09/22/introducing-the-new-jsx-transform.html">新しい JSX トランスフォーム</a>をサポートします。このサポートは React 16.14.0、React 15.7.0、React 0.14.10 にもバックポートされています。これは完全にオプトインであり、使う必要はないということに留意してください。以前の JSX トランスフォームも動作し続けますし、サポートを終了する予定はありません。</p>
<h2 id="react-native"><a href="#react-native" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Native </h2>
<p>React Native のリリーススケジュールは React と異なっています。React 17 へのサポートは React Native 0.64 にて追加されました。いつものように、リリースに関する議論は React Native Community のリリースに関する<a href="https://github.com/react-native-community/releases" target="_blank" rel="nofollow noopener noreferrer">イシュートラッカ</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>インストール </h2>
<p>React 17 を npm でインストールするには以下のようにします：</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>React 17 を 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@17.0.0 react-dom@17.0.0</code></pre></div>
<p>CDN 経由で React の UMD ビルドも提供しています：</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><a href="/docs/installation.html">詳細なインストール手順</a>についてはドキュメントを参照してください。</p>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li>Add <code class="gatsby-code-text">react/jsx-runtime</code> and <code class="gatsby-code-text">react/jsx-dev-runtime</code> for the <a href="https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154-https-githubcom-babel-babel-pull-11154" target="_blank" rel="nofollow noopener noreferrer">new JSX transform</a>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> in <a href="https://github.com/facebook/react/pull/18299" target="_blank" rel="nofollow noopener noreferrer">#18299</a>)</li>
<li>Build component stacks from native error frames. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">#18561</a>)</li>
<li>Allow to specify <code class="gatsby-code-text">displayName</code> on context for improved stacks. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18224" target="_blank" rel="nofollow noopener noreferrer">#18224</a>)</li>
<li>Prevent <code class="gatsby-code-text">'use strict'</code> from leaking in the UMD bundles. (<a href="https://github.com/koba04" target="_blank" rel="nofollow noopener noreferrer">@koba04</a> in <a href="https://github.com/facebook/react/pull/19614" target="_blank" rel="nofollow noopener noreferrer">#19614</a>)</li>
<li>Stop using <code class="gatsby-code-text">fb.me</code> for redirects. (<a href="https://github.com/cylim" target="_blank" rel="nofollow noopener noreferrer">@cylim</a> in <a href="https://github.com/facebook/react/pull/19598" target="_blank" rel="nofollow noopener noreferrer">#19598</a>)</li>
</ul>
<h3 id="react-dom"><a href="#react-dom" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM </h3>
<ul>
<li>Delegate events to roots instead of <code class="gatsby-code-text">document</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18195" target="_blank" rel="nofollow noopener noreferrer">#18195</a> and <a href="https://github.com/facebook/react/pulls?q=is%3Apr+author%3Atrueadm+modern+event+is%3Amerged" target="_blank" rel="nofollow noopener noreferrer">others</a>)</li>
<li>Clean up all effects before running any next effects. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17947" target="_blank" rel="nofollow noopener noreferrer">#17947</a>)</li>
<li>Run <code class="gatsby-code-text">useEffect</code> cleanup functions asynchronously. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17925" target="_blank" rel="nofollow noopener noreferrer">#17925</a>)</li>
<li>Use browser <code class="gatsby-code-text">focusin</code> and <code class="gatsby-code-text">focusout</code> for <code class="gatsby-code-text">onFocus</code> and <code class="gatsby-code-text">onBlur</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/19186" target="_blank" rel="nofollow noopener noreferrer">#19186</a>)</li>
<li>Make all <code class="gatsby-code-text">Capture</code> events use the browser capture phase. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/19221" target="_blank" rel="nofollow noopener noreferrer">#19221</a>)</li>
<li>Don’t emulate bubbling of the <code class="gatsby-code-text">onScroll</code> event. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19464" target="_blank" rel="nofollow noopener noreferrer">#19464</a>)</li>
<li>Throw if <code class="gatsby-code-text">forwardRef</code> or <code class="gatsby-code-text">memo</code> component returns <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Remove event pooling. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18969" target="_blank" rel="nofollow noopener noreferrer">#18969</a>)</li>
<li>Stop exposing internals that won’t be needed by React Native Web. (<a href="https://github.com/necolas" target="_blank" rel="nofollow noopener noreferrer">@necolas</a> in <a href="https://github.com/facebook/react/pull/18483" target="_blank" rel="nofollow noopener noreferrer">#18483</a>)</li>
<li>Attach all known event listeners when the root mounts. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19659" target="_blank" rel="nofollow noopener noreferrer">#19659</a>)</li>
<li>Disable <code class="gatsby-code-text">console</code> in the second render pass of DEV mode double render. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>Deprecate the undocumented and misleading <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code> API. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/13407" target="_blank" rel="nofollow noopener noreferrer">#13407</a>)</li>
<li>Rename private field names used in the internals. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/18377" target="_blank" rel="nofollow noopener noreferrer">#18377</a>)</li>
<li>Don’t call User Timing API in development. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/18417" target="_blank" rel="nofollow noopener noreferrer">#18417</a>)</li>
<li>Disable console during the repeated render in Strict Mode. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>In Strict Mode, double-render components without Hooks too. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18430" target="_blank" rel="nofollow noopener noreferrer">#18430</a>)</li>
<li>Allow calling <code class="gatsby-code-text">ReactDOM.flushSync</code> during lifecycle methods (but warn). (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18759" target="_blank" rel="nofollow noopener noreferrer">#18759</a>)</li>
<li>Add the <code class="gatsby-code-text">code</code> property to the keyboard event objects. (<a href="https://github.com/bl00mber" target="_blank" rel="nofollow noopener noreferrer">@bl00mber</a> in <a href="https://github.com/facebook/react/pull/18287" target="_blank" rel="nofollow noopener noreferrer">#18287</a>)</li>
<li>Add the <code class="gatsby-code-text">disableRemotePlayback</code> property for <code class="gatsby-code-text">video</code> elements. (<a href="https://github.com/tombrowndev" target="_blank" rel="nofollow noopener noreferrer">@tombrowndev</a> in <a href="https://github.com/facebook/react/pull/18619" target="_blank" rel="nofollow noopener noreferrer">#18619</a>)</li>
<li>Add the <code class="gatsby-code-text">enterKeyHint</code> property for <code class="gatsby-code-text">input</code> elements. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18634" target="_blank" rel="nofollow noopener noreferrer">#18634</a>)</li>
<li>Warn when no <code class="gatsby-code-text">value</code> is provided to <code class="gatsby-code-text">&lt;Context.Provider></code>. (<a href="https://github.com/charlie1404" target="_blank" rel="nofollow noopener noreferrer">@charlie1404</a> in <a href="https://github.com/facebook/react/pull/19054" target="_blank" rel="nofollow noopener noreferrer">#19054</a>)</li>
<li>Warn when <code class="gatsby-code-text">memo</code> or <code class="gatsby-code-text">forwardRef</code> components return <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Improve the error message for invalid updates. (<a href="https://github.com/JoviDeCroock" target="_blank" rel="nofollow noopener noreferrer">@JoviDeCroock</a> in <a href="https://github.com/facebook/react/pull/18316" target="_blank" rel="nofollow noopener noreferrer">#18316</a>)</li>
<li>Exclude forwardRef and memo from stack frames. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18559" target="_blank" rel="nofollow noopener noreferrer">#18559</a>)</li>
<li>Improve the error message when switching between controlled and uncontrolled inputs. (<a href="https://github.com/vcarl" target="_blank" rel="nofollow noopener noreferrer">@vcarl</a> in <a href="https://github.com/facebook/react/pull/17070" target="_blank" rel="nofollow noopener noreferrer">#17070</a>)</li>
<li>Keep <code class="gatsby-code-text">onTouchStart</code>, <code class="gatsby-code-text">onTouchMove</code>, and <code class="gatsby-code-text">onWheel</code> passive. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19654" target="_blank" rel="nofollow noopener noreferrer">#19654</a>)</li>
<li>Fix <code class="gatsby-code-text">setState</code> hanging in development inside a closed iframe. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19220" target="_blank" rel="nofollow noopener noreferrer">#19220</a>)</li>
<li>Fix rendering bailout for lazy components with <code class="gatsby-code-text">defaultProps</code>. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> in <a href="https://github.com/facebook/react/pull/18539" target="_blank" rel="nofollow noopener noreferrer">#18539</a>)</li>
<li>Fix a false positive warning when <code class="gatsby-code-text">dangerouslySetInnerHTML</code> is <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18676" target="_blank" rel="nofollow noopener noreferrer">#18676</a>)</li>
<li>Fix Test Utils with non-standard <code class="gatsby-code-text">require</code> implementation. (<a href="https://github.com/just-boris" target="_blank" rel="nofollow noopener noreferrer">@just-boris</a> in <a href="https://github.com/facebook/react/pull/18632" target="_blank" rel="nofollow noopener noreferrer">#18632</a>)</li>
<li>Fix <code class="gatsby-code-text">onBeforeInput</code> reporting an incorrect <code class="gatsby-code-text">event.type</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/19561" target="_blank" rel="nofollow noopener noreferrer">#19561</a>)</li>
<li>Fix <code class="gatsby-code-text">event.relatedTarget</code> reported as <code class="gatsby-code-text">undefined</code> in Firefox. (<a href="https://github.com/claytercek" target="_blank" rel="nofollow noopener noreferrer">@claytercek</a> in <a href="https://github.com/facebook/react/pull/19607" target="_blank" rel="nofollow noopener noreferrer">#19607</a>)</li>
<li>Fix “unspecified error” in IE11. (<a href="https://github.com/hemakshis" target="_blank" rel="nofollow noopener noreferrer">@hemakshis</a> in <a href="https://github.com/facebook/react/pull/19664" target="_blank" rel="nofollow noopener noreferrer">#19664</a>)</li>
<li>Fix rendering into a shadow root. (<a href="https://github.com/Jack-Works" target="_blank" rel="nofollow noopener noreferrer">@Jack-Works</a> in <a href="https://github.com/facebook/react/pull/15894" target="_blank" rel="nofollow noopener noreferrer">#15894</a>)</li>
<li>Fix <code class="gatsby-code-text">movementX/Y</code> polyfill with capture events. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19672" target="_blank" rel="nofollow noopener noreferrer">#19672</a>)</li>
<li>Use delegation for <code class="gatsby-code-text">onSubmit</code> and <code class="gatsby-code-text">onReset</code> events. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19333" target="_blank" rel="nofollow noopener noreferrer">#19333</a>)</li>
<li>Improve memory usage. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18970" target="_blank" rel="nofollow noopener noreferrer">#18970</a>)</li>
</ul>
<h3 id="react-dom-server"><a href="#react-dom-server" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Server </h3>
<ul>
<li>Make <code class="gatsby-code-text">useCallback</code> behavior consistent with <code class="gatsby-code-text">useMemo</code> for the server renderer. (<a href="https://github.com/alexmckenley" target="_blank" rel="nofollow noopener noreferrer">@alexmckenley</a> in <a href="https://github.com/facebook/react/pull/18783" target="_blank" rel="nofollow noopener noreferrer">#18783</a>)</li>
<li>Fix state leaking when a function component throws. (<a href="https://github.com/pmaccart" target="_blank" rel="nofollow noopener noreferrer">@pmaccart</a> in <a href="https://github.com/facebook/react/pull/19212" target="_blank" rel="nofollow noopener noreferrer">#19212</a>)</li>
</ul>
<h3 id="react-test-renderer"><a href="#react-test-renderer" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Test Renderer </h3>
<ul>
<li>Improve <code class="gatsby-code-text">findByType</code> error message. (<a href="https://github.com/henryqdineen" target="_blank" rel="nofollow noopener noreferrer">@henryqdineen</a> in <a href="https://github.com/facebook/react/pull/17439" target="_blank" rel="nofollow noopener noreferrer">#17439</a>)</li>
</ul>
<h3 id="concurrent-mode-experimental"><a href="#concurrent-mode-experimental" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Concurrent Mode (Experimental) </h3>
<ul>
<li>Revamp the priority batching heuristics. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18796" target="_blank" rel="nofollow noopener noreferrer">#18796</a>)</li>
<li>Add the <code class="gatsby-code-text">unstable_</code> prefix before the experimental APIs. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remove <code class="gatsby-code-text">unstable_discreteUpdates</code> and <code class="gatsby-code-text">unstable_flushDiscreteUpdates</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remove the <code class="gatsby-code-text">timeoutMs</code> argument. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/19703" target="_blank" rel="nofollow noopener noreferrer">#19703</a>)</li>
<li>Disable <code class="gatsby-code-text">&lt;div hidden /></code> prerendering in favor of a different future API. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18917" target="_blank" rel="nofollow noopener noreferrer">#18917</a>)</li>
<li>Add <code class="gatsby-code-text">unstable_expectedLoadTime</code> to Suspense for CPU-bound trees. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/19936" target="_blank" rel="nofollow noopener noreferrer">#19936</a>)</li>
<li>Add an experimental <code class="gatsby-code-text">unstable_useOpaqueIdentifier</code> Hook. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> in <a href="https://github.com/facebook/react/pull/17322" target="_blank" rel="nofollow noopener noreferrer">#17322</a>)</li>
<li>Add an experimental <code class="gatsby-code-text">unstable_startTransition</code> API. (<a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a> in <a href="https://github.com/facebook/react/pull/19696" target="_blank" rel="nofollow noopener noreferrer">#19696</a>)</li>
<li>Using <code class="gatsby-code-text">act</code> in the test renderer no longer flushes Suspense fallbacks. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18596" target="_blank" rel="nofollow noopener noreferrer">#18596</a>)</li>
<li>Use global render timeout for CPU Suspense. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/19643" target="_blank" rel="nofollow noopener noreferrer">#19643</a>)</li>
<li>Clear the existing root content before mounting. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18730" target="_blank" rel="nofollow noopener noreferrer">#18730</a>)</li>
<li>Fix a bug with error boundaries. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18265" target="_blank" rel="nofollow noopener noreferrer">#18265</a>)</li>
<li>Fix a bug causing dropped updates in a suspended tree. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18384" target="_blank" rel="nofollow noopener noreferrer">#18384</a> and <a href="https://github.com/facebook/react/pull/18457" target="_blank" rel="nofollow noopener noreferrer">#18457</a>)</li>
<li>Fix a bug causing dropped render phase updates. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18537" target="_blank" rel="nofollow noopener noreferrer">#18537</a>)</li>
<li>Fix a bug in SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18412" target="_blank" rel="nofollow noopener noreferrer">#18412</a>)</li>
<li>Fix a bug causing Suspense fallback to show too early. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18411" target="_blank" rel="nofollow noopener noreferrer">#18411</a>)</li>
<li>Fix a bug with class components inside SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18448" target="_blank" rel="nofollow noopener noreferrer">#18448</a>)</li>
<li>Fix a bug with inputs that may cause updates to be dropped. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> in <a href="https://github.com/facebook/react/pull/18515" target="_blank" rel="nofollow noopener noreferrer">#18515</a> and <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18535" target="_blank" rel="nofollow noopener noreferrer">#18535</a>)</li>
<li>Fix a bug causing Suspense fallback to get stuck.  (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18663" target="_blank" rel="nofollow noopener noreferrer">#18663</a>)</li>
<li>Don’t cut off the tail of a SuspenseList if hydrating. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18854" target="_blank" rel="nofollow noopener noreferrer">#18854</a>)</li>
<li>Fix a bug in <code class="gatsby-code-text">useMutableSource</code> that may happen when <code class="gatsby-code-text">getSnapshot</code> changes. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18297" target="_blank" rel="nofollow noopener noreferrer">#18297</a>)</li>
<li>Fix a tearing bug in <code class="gatsby-code-text">useMutableSource</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18912" target="_blank" rel="nofollow noopener noreferrer">#18912</a>)</li>
<li>Warn if calling setState outside of render but before commit. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18838" target="_blank" rel="nofollow noopener noreferrer">#18838</a>)</li>
</ul>]]></description><link>https://ja.reactjs.org/blog/2020/10/20/react-v17.html</link><guid isPermaLink="false">https://ja.reactjs.org/blog/2020/10/20/react-v17.html</guid><pubDate>Tue, 20 Oct 2020 00:00:00 GMT</pubDate></item><item><title><![CDATA[新しい JSX トランスフォーム]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p>React 17 には<a href="/blog/2020/08/10/react-v17-rc.html">新機能はありません</a>が、新バージョンの JSX トランスフォーム (JSX transform) に対応します。この記事ではこれがどのようなもので、どのように試せるのかについて説明します。</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>JSX トランスフォームとは？ </h2>
<p>ブラウザはそのままでは JSX を理解しないため、ほとんどの React ユーザは、Babel や TypeScript のようなコンパイラを利用して <strong>JSX コードを通常の JavaScript に変換 (transform)</strong> しています。Create React App や Next.js のような多くの設定済みツールキットも、裏では JSX トランスフォーム機能を搭載しています。</p>
<p>React 17 のリリースとともに、JSX トランスフォームにいくつかの改良を加えたいと思っていましたが、既存のセットアップを壊したくもありませんでした。そのため、<a href="https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154httpsgithubcombabelbabelpull11154" target="_blank" rel="nofollow noopener noreferrer">Babel と協力</a>して、アップグレードしたい人のために JSX トランスフォームの新バージョンを提供することにしました。</p>
<p>新しいトランスフォームへのアップグレードは完全に任意ですが、いくつかの利点があります。</p>
<ul>
<li>新版のトランスフォームでは、<strong>React をインポートせず</strong> JSX を使用できます。</li>
<li>セットアップによっては、コンパイル後のバンドルサイズをわずかに改善できる可能性があります。</li>
<li>将来的に、React を学ぶために<strong>覚える必要がある概念の数を減らす</strong>ような改善が可能になります。</li>
</ul>
<p><strong>このアップグレードは JSX の構文を変更するものではなく、必須でもありません</strong>。以前の JSX トランスフォームもこれまで通り動作し続けますし、それらのサポートを削除する予定もありません。</p>
<p><a href="/blog/2020/08/10/react-v17-rc.html">React 17 RC</a> にはすでに新しいトランスフォームのサポートが含まれていますので、試してみてください。より簡単に導入できるよう、React 16.14.0、React 15.7.0、React 0.14.10 への<strong>バックポートも行っています</strong>。<a href="#how-to-upgrade-to-the-new-jsx-transform">記事の後半</a>で様々なツールにおけるアップグレード方法を記載しています。</p>
<p>では、新旧のトランスフォームの違いを詳しく見ていきましょう。</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>新しいトランスフォームは何が違うのか？ </h2>
<p>JSX を使うと、コンパイラはそれをブラウザが理解できる React の関数呼び出しに変換します。<strong>以前の JSX トランスフォーム機能</strong>では、JSX を <code class="gatsby-code-text">React.createElement(...)</code> 呼び出しに変換していました。</p>
<p>例えば、ソースコードが以下のようになっているとします。</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>裏側では、以前の JSX トランスフォームはこれを以下のような通常の JavaScript に変換します。</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> React <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> React<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'h1'</span><span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">,</span> <span class="token string">'Hello world'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<blockquote>
<p>補足</p>
<p><strong>あなたのソースコードをこう変えろという話ではありません。</strong>これは、JSX トランスフォームがあなたの JSX ソースコードをブラウザが理解できるコードへとどのように変換するのかを説明しているものです。</p>
</blockquote>
<p>しかし、これで完璧とは言えません。</p>
<ul>
<li>JSX が <code class="gatsby-code-text">React.createElement</code> へとコンパイルされるため、JSX を使用する場合は <code class="gatsby-code-text">React</code> をスコープに入れる必要がありました。</li>
<li><code class="gatsby-code-text">React.createElement</code> では行えない<a href="https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#motivation" target="_blank" rel="nofollow noopener noreferrer">パフォーマンス向上と単純化方法</a>がいくつか存在します。</li>
</ul>
<p>これらの問題を解決するために、React 17 では React パッケージに、Babel や TypeScript のようなコンパイラのみが使用することを意図した 2 つの新しいエントリポイントを導入しています。JSX を <code class="gatsby-code-text">React.createElement</code> に変換する代わりに、<strong>新しい JSX トランスフォーム</strong>は、React パッケージのこれらの新しいエントリポイントから特別な関数を自動的にインポートし、それらを呼び出します。</p>
<p>ソースコードが以下のようになっているとしましょう。</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>新しい JSX トランスフォームは、これをこのようなコードにコンパイルします。</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// Inserted by a compiler (don't import it yourself!)</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span>jsx <span class="token keyword">as</span> _jsx<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react/jsx-runtime'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token function">_jsx</span><span class="token punctuation">(</span><span class="token string">'h1'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">children</span><span class="token operator">:</span> <span class="token string">'Hello world'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>JSX を使用するために <strong>React をインポートする必要がなくなっている</strong>ことに注意してください！（ただし、React が提供するフックやその他のエクスポートを使用するためには、引き続き React をインポートする必要があります）。</p>
<p><strong>この変更は、既存のあらゆる JSX コードと完全に互換性があります</strong>ので、あなたのコンポーネントを変更する必要はありません。興味がある方は、新しいトランスフォームがどのように動作するかの詳細について<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</a> をチェックしてみてください。</p>
<blockquote>
<p>補足</p>
<p><code class="gatsby-code-text">react/jsx-runtime</code> と <code class="gatsby-code-text">react/jsx-dev-runtime</code> 内の関数は、コンパイラによるトランスフォーム機能によってのみ使用されなければなりません。コードの中で手動で要素を作成する必要がある場合は、<code class="gatsby-code-text">React.createElement</code> を使い続けるべきです。これは動作し続けますし、なくなることはありません。</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>新しい JSX トランスフォームへのアップグレード </h2>
<p>新しい JSX トランスフォームにアップグレードする準備ができていない場合や、別のライブラリで JSX を使用している場合でも、心配は要りません。古いトランスフォームは削除されず、引き続きサポートされます。</p>
<p>アップグレードしたい場合は、以下の 2 つのものが必要です。</p>
<ul>
<li><strong>新しいトランスフォームをサポートする React のバージョン</strong>（<a href="/blog/2020/08/10/react-v17-rc.html">React 17 RC</a> 以降でサポートされますが、以前のメジャーバージョンに留まりたい方のために React 16.10.0、React 15.7.0、React 0.14.10 もリリースしてあります）。</li>
<li><strong>互換性のあるコンパイラ</strong>（下記のツールごとの説明を参照）。</li>
</ul>
<p>新しい JSX 変換は React をスコープに入れる必要がないので、コードベースから不要なインポートを削除する<a href="#removing-unused-react-imports">自動化スクリプトも用意しました</a>。</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> 以降で互換性のある 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> 以降、互換性のある 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> 以降、互換性のある React のバージョンに対して新しいトランスフォームを使用します。</p>
<blockquote>
<p>補足</p>
<p>React 17 RC にアップグレードした後に<a href="https://github.com/gatsbyjs/gatsby/issues/26979" target="_blank" rel="nofollow noopener noreferrer">この Gatsby エラー</a>が出た場合は、<code class="gatsby-code-text">npm update</code> を実行することで修正できます。</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>Babel の手動セットアップ </h3>
<p>新しい JSX トランスフォームのサポートは、Babel <a href="https://babeljs.io/blog/2020/03/16/7.9.0" target="_blank" rel="nofollow noopener noreferrer">v7.9.0</a> 以上で利用可能です。</p>
<p>まず、最新の Babel とトランスフォームプラグインにアップデートする必要があります。</p>
<p><code class="gatsby-code-text">@babel/plugin-transform-react-jsx</code> を利用している場合：</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for npm users</span>
<span class="token function">npm</span> update @babel/core @babel/plugin-transform-react-jsx</code></pre></div>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for yarn users</span>
<span class="token function">yarn</span> upgrade @babel/core @babel/plugin-transform-react-jsx</code></pre></div>
<p><code class="gatsby-code-text">@babel/preset-react</code> を利用している場合：</p>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for npm users</span>
<span class="token function">npm</span> update @babel/core @babel/preset-react</code></pre></div>
<div class="gatsby-highlight" data-language="bash"><pre class="gatsby-code-bash"><code class="gatsby-code-bash"><span class="token comment"># for yarn users</span>
<span class="token function">yarn</span> upgrade @babel/core @babel/preset-react</code></pre></div>
<p>現在のところは以前のトランスフォーム <code class="gatsby-code-text">{"runtime": "classic"}</code> がデフォルトのオプションです。新しいトランスフォームを有効にするには、<code class="gatsby-code-text">@babel/plugin-transform-react-jsx</code> ないし <code class="gatsby-code-text">@babel/preset-react</code> のオプションとして <code class="gatsby-code-text">{"runtime": "automatic"}</code> を渡してください。</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// If you are using @babel/preset-react</span>
<span class="token punctuation">{</span>
  <span class="token string-property property">"presets"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">[</span><span class="token string">"@babel/preset-react"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
      <span class="token string-property property">"runtime"</span><span class="token operator">:</span> <span class="token string">"automatic"</span>
    <span class="token punctuation">}</span><span class="token punctuation">]</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span></code></pre></div>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token comment">// If you're using @babel/plugin-transform-react-jsx</span>
<span class="token punctuation">{</span>
  <span class="token string-property property">"plugins"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">[</span><span class="token string">"@babel/plugin-transform-react-jsx"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
      <span class="token string-property property">"runtime"</span><span class="token operator">:</span> <span class="token string">"automatic"</span>
    <span class="token punctuation">}</span><span class="token punctuation">]</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span></code></pre></div>
<p>Babel 8 からは、<code class="gatsby-code-text">"automatic"</code> が両方のプラグインでデフォルトのランタイムとなります。詳細については、Babel ドキュメントの <a href="https://babeljs.io/docs/en/babel-plugin-transform-react-jsx" target="_blank" rel="nofollow noopener noreferrer">@babel/plugin-transform-react-jsx</a> と <a href="https://babeljs.io/docs/en/babel-preset-react" target="_blank" rel="nofollow noopener noreferrer">@babel/preset-react</a> を参照してください。</p>
<blockquote>
<p>補足</p>
<p>JSX を React 以外のライブラリで使用している場合、そのライブラリが必要なエントリポイントを提供しているのであれば、<a href="https://babeljs.io/docs/en/babel-preset-react#importsource" target="_blank" rel="nofollow noopener noreferrer"><code class="gatsby-code-text">importSource</code> オプション</a> を使ってそこからインポートするよう指定することができます。あるいは、引き続きサポートされる旧版のトランスフォームを使い続けることもできます。</p>
<p>ライブラリ作者の方で <code class="gatsby-code-text">/jsx-runtime</code> エントリポイントをあなたのライブラリに実装しようとしている場合、後方互換性のため新しいトランスフォームが <code class="gatsby-code-text">createElement</code> にフォールバックする<a href="https://github.com/facebook/react/issues/20031#issuecomment-710346866" target="_blank" rel="nofollow noopener noreferrer">ケースがある</a>ことに留意してください。この場合、<code class="gatsby-code-text">importSource</code> に指定された<strong>ルート</strong>エントリポイントから <code class="gatsby-code-text">createElement</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><a href="https://github.com/yannickcr/eslint-plugin-react" target="_blank" rel="nofollow noopener noreferrer">eslint-plugin-react</a> を使用している場合、<code class="gatsby-code-text">react/jsx-uses-react</code> と <code class="gatsby-code-text">react/react-in-jsx-scope</code> のルールは不要になりますので、無効にするか削除することができます。</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 は新しい JSX トランスフォームを <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 <a href="https://github.com/facebook/flow/releases/tag/v0.126.0" target="_blank" rel="nofollow noopener noreferrer">v0.126.0</a> 以降で、設定オプションに <code class="gatsby-code-text">react.runtime=automatic</code> を追加することで新しい JSX トランスフォームをサポートします。</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>未使用 React インポートの削除 </h2>
<p>新しい JSX トランスフォームは、必要とする <code class="gatsby-code-text">react/jsx-runtime</code> 関数を自動的にインポートするため、JSX を使用する際に React をスコープに入れる必要がなくなります。これにより、コードの中で React のインポートが未使用となる可能性があります。残しておいても害はありませんが、削除したい場合は <a href="https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb" target="_blank" rel="nofollow noopener noreferrer">“codemod”</a> スクリプトを実行して自動的に行うことをお勧めします。</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>補足</p>
<p>codemod の実行時にエラーが出る場合は、<code class="gatsby-code-text">npx react-codemod update-react-imports</code> で別の JavaScript の方言を指定してみてください。特に、現時点では “JavaScript with Flow” の設定は、“JavaScript” の設定よりも新しい構文をサポートしていますので、Flow を使用していない場合でも試してみてください。問題が発生した場合は <a href="https://github.com/reactjs/react-codemod/issues" target="_blank" rel="nofollow noopener noreferrer">issue を報告</a> してください。</p>
<p>また、codemod の出力はあなたのプロジェクトのコーディングスタイルと必ずしも一致はしませんので、一貫したフォーマットにするため codemod の終了後に <a href="https://prettier.io/" target="_blank" rel="nofollow noopener noreferrer">Prettier</a> を実行すると良いかもしれません。</p>
</blockquote>
<p>この codemod を実行すると以下のことを行います：</p>
<ul>
<li>新しい JSX トランスフォームにアップグレードした結果使用されなくなる React のインポートをすべて削除します。</li>
<li>すべての React のデフォルトインポート（すなわち、<code class="gatsby-code-text">import React from "react"</code>）を、将来的に望ましいスタイルである分割代入型の名前付きインポート（例えば、<code class="gatsby-code-text">import { useState } from "react"</code>）に変更します。名前空間インポート（すなわち、<code class="gatsby-code-text">import * as React from "react"</code>）も有効な形式であり、codemod はこれらは変換<strong>しません</strong>。デフォルトインポートは React 17 でも動作し続けますが、長期的にはそれらのインポートを利用しないようにすることを推奨します。</li>
</ul>
<p>例えば、</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>は、以下に置き換わります：</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>他のもの（例えばフック）を React からインポートしている場合は、codemod はそれらを名前付きインポートへと変換します。</p>
<p>例えば、</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> React <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> <span class="token punctuation">[</span>text<span class="token punctuation">,</span> setText<span class="token punctuation">]</span> <span class="token operator">=</span> React<span class="token punctuation">.</span><span class="token function">useState</span><span class="token punctuation">(</span><span class="token string">'Hello World'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>text<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>は、以下に置き換わります：</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">import</span> <span class="token punctuation">{</span> useState <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">App</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> <span class="token punctuation">[</span>text<span class="token punctuation">,</span> setText<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token function">useState</span><span class="token punctuation">(</span><span class="token string">'Hello World'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>text<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
<p>未使用のインポートをクリーンアップすることに加えて、これは ES Modules をサポートしデフォルトエクスポートを持たない将来のメジャーバージョンの React（React 17 のことではありません）への準備にも役立ちます。</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>謝辞 </h2>
<p>新しい JSX トランスフォームの実装と統合を手伝っていただいた Babel、TypeScript、Create React App、Next.js、Gatsby、ESLint および Flow のメンテナの方々に感謝します。また、<a href="https://github.com/reactjs/rfcs/pull/107" target="_blank" rel="nofollow noopener noreferrer">テクニカル RFC</a> においてフィードバックや議論をしていただいた React コミュニティにも感謝します。</p>]]></description><link>https://ja.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html</link><guid isPermaLink="false">https://ja.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html</guid><pubDate>Tue, 22 Sep 2020 00:00:00 GMT</pubDate></item><item><title><![CDATA[React v17.0 Release Candidate: 新機能「なし」]]></title><description><![CDATA[<div class="scary">
<blockquote>
<p>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p>本日 React 17 の最初のリリース候補を公開します。<a href="/blog/2017/09/26/react-v16.0.html">前回の React メジャーリリース</a>から 2 年半が経過しており、これは我々の基準からしても長いものです！ このブログ記事では、このメジャーリリースの役割、期待される変化、そしてどのように試すことができるのかについて説明します。</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>新機能 “なし” </h2>
<p>この React 17 リリースは普段のリリースと異なっており、開発者向けの新機能が何も追加されていません。代わりに、このリリースは <strong>React 自体のアップグレードを簡単にすること</strong>に焦点を当てています。</p>
<p>我々は React の新機能を積極的に開発中ですが、それらの新機能はこのリリースに含まれていません。React 17 のリリースは、誰も取り残されないようにしつつ新機能を展開していくという私たちの戦略の鍵となるものです。</p>
<p>具体的には React 17 は、あるバージョンの React で管理されるツリー内に、別のバージョンの React で管理されるツリーをより安全に埋め込めるようにするための、<strong>「踏み台」となるリリース</strong>となっています。</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>段階的なアップグレード </h2>
<p>過去 7 年間、React のアップグレードは “all-or-nothing” 型でした。古いバージョンにとどまり続けるか、新バージョンにアプリ全体をアップグレードするかの二択です。その中間は存在しませんでした。</p>
<p>これまではそれで何とかなっていましたが、我々は “all-or-nothing” なアップグレード戦略の限界に直面しています。例えば、<a href="/docs/legacy-context.html">古いコンテクスト API</a> の非推奨化のようないくつかの API 変更への対応は、自動化して行うことができません。最近に書かれたアプリのほとんどはこれを一切使っていないにも関わらず、React はこれをサポートし続けています。ずっとこれをサポートし続けるか、幾つかのアプリを古いバージョンの React のまま取り残すしかしかないのです。どちらの選択肢もあまり望ましくありません。</p>
<p>そこで我々はもうひとつの選択肢を用意することにしました。</p>
<p><strong>React 17 は段階的な React のアップグレードを可能にします。</strong>React 15 から 16 に（そして近い将来 React 16 から 17 に）アップグレードする場合、普通はアプリ全体をまとめてアップグレードします。これは多くのアプリではうまく行きます。しかしコードが数年以上前に書かれており活発にメンテされていないような場合、だんだんと難易度が増していきます。ページ内で 2 つの React のバージョンを混在させることは可能ですが、React 17 以前にこのようなことをすると不安定になり、イベント絡みの問題が引き起こされていました。</p>
<p>React 17 で、これらの問題の多くを修正します。これは <strong>React 18 やもっと将来のバージョンが来たときに、とれる選択肢が増える</strong>ということを意味します。選択肢のひとつは、これまでやってきたのと同様、アプリ全体を一度にアップグレードするというものです。しかし今後は、アプリを一部分ずつアップグレードするという選択肢がとれるようになります。例えば、アプリの大部分を React 18 に移行しつつ、いくつかの遅延ロードされるダイアログやサブページを React 17 のままにしておけるようになります。</p>
<p>だからといって段階的に更新<em class="em-ja">しないといけない</em>という訳ではありません。今後もほとんどのアプリでは、一気にアップグレードするのがベストの選択肢です。2 つのバージョンの React をロードするというのは、たとえ片方はオンデマンドで遅延ロードするのだとしても、やはり理想的ではありません。しかし、活発にメンテされていない大きなアプリではこの選択肢は検討に値するものであり、React 17 はこのようなアプリが取り残されずに済むようにします。</p>
<p>段階的なアップグレードを可能にするために、React のイベントシステムに幾つかの変更を加える必要がありました。React 17 がメジャーリリースとなっているのは、これらの変更が一部互換性の問題を引き起こす可能性があるからです。実際のところは、10 万を超えるコンポーネントの中で変更する必要があったのは 20 未満でしたので、<strong>ほとんどのアプリは React 17 にトラブルなく移行できる</strong>と考えています。問題があった場合は<a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">知らせてください</a>。</p>
<h3 id="demo-of-gradual-upgrades"><a href="#demo-of-gradual-upgrades" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>段階的アップグレードのデモ </h3>
<p>古いバージョンの React を必要に応じて遅延ロードするという手法をデモするための<a href="https://github.com/reactjs/react-gradual-upgrade-demo/" target="_blank" rel="nofollow noopener noreferrer">サンプルリポジトリ</a>を用意しました。このデモは Create React App を使っていますが、他のどのようなツールでも似たアプローチが可能なはずです。他のツールを使ったデモを追加するプルリクエストを歓迎します。</p>
<blockquote>
<p>補足</p>
<p>その他の変更は React 17 より後に<strong>延期しました</strong>。このリリースの目標は段階的なアップグレードを可能にすることです。React 17 自体へのアップグレードが難しいようでは本リリースの目的が台無しですので、そのようなことはないはずです。</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>イベントデリゲーションに関する変更 </h2>
<p>異なるバージョンの React で作成されたアプリをネストさせることは、技術的にはこれまでも可能でしたが、React のイベントシステムの挙動に起因して不安定なものとなっていました。</p>
<p>React コンポーネントでは、通常はイベントハンドラをインラインで記載します：</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>このコードは素の DOM では以下と同等です：</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>しかし、ほとんどのイベントでは、実際には React はあなたが宣言した DOM ノードにイベントハンドラをアタッチするのではありません。代わりに、イベントタイプごとにハンドラを 1 つだけ、<code class="gatsby-code-text">document</code> ノードに直接アタッチします。これは<a href="https://davidwalsh.name/event-delegate" target="_blank" rel="nofollow noopener noreferrer">イベントデリゲーション</a>（event delegation; イベントの委譲）と呼ばれます。大きなアプリケーションツリーではパフォーマンス面で有利であるということに加え、これにより<a href="https://twitter.com/dan_abramov/status/1200118229697486849" target="_blank" rel="nofollow noopener noreferrer">イベントのリプレイ</a>といった新機能も追加しやすくなります。</p>
<p>React は最初のリリース時点からこのようなイベントデリゲーションを自動的に行っていました。ドキュメントで DOM イベントが発生すると、React はどのコンポーネントを呼び出すべきか判定し、React のイベントがあなたのコンポーネントツリー内を上側に向かって「バブリング」していきます。しかしその裏側では、この時点でネイティブのイベントが既に <code class="gatsby-code-text">document</code> のレベルにバブリングし終わっているのであり、そこに React はイベントハンドラを仕込んでいるのです。</p>
<p>ところがこの挙動が、段階的なアップグレードにおいて問題を引き起こします。</p>
<p>ページ内に複数の React バージョンがあると、それらがすべてイベントハンドラをトップレベルに登録します。これにより <code class="gatsby-code-text">e.stopPropagation()</code> がおかしくなります。例えばネストされている側のツリーがとあるイベントの伝播を停止した場合でも、外側のツリーがそれを受け取ることができてしまいます。これが複数の異なるバージョンの React をネストさせるのが難しかった理由です。この懸念は架空の話ではなく、例えば Atom エディタは 4 年前に<a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">実際にこの問題に遭遇</a>しています。</p>
<p>以上が、React が裏で DOM にイベントをアタッチする方法を、我々が変更しようとしている理由です。</p>
<p><strong>React 17 では、React は <code class="gatsby-code-text">document</code> レベルにイベントハンドラをアタッチしないようになります。代わりに、あなたが React ツリーをレンダーしようとしているルート DOM コンテナに対してアタッチするようになります。</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>React 16 およびそれ以前では、React はほとんどのイベントに対して <code class="gatsby-code-text">document.addEventListener()</code> のようにしていました。代わりに React 17 は、水面下で <code class="gatsby-code-text">rootNode.addEventListener()</code> という呼び出しを行うようになります。</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="React 17 ではイベントハンドラをドキュメントではなくルート要素にアタッチしていることを示す図"
        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>この変更のおかげで、<strong>あるバージョンの React で管理されているツリーを別バージョンの React で管理されているツリー内に埋め込むことが、より安全に行えるようになります</strong>。ただしこれがうまく働くためにはどちらの React のバージョンも 17 以上である必要があり、これが React 17 にアップグレードすることが重要である理由です。ある意味で、React 17 は、今回以降に段階的なアップグレードを行いやすくするための「踏み台」リリースであると言えます。</p>
<p>この変更により、<strong>他のテクノロジーで構築されたアプリ内に React を組み込むことも容易になります</strong>。例えば、外見の大部分を jQuery で書いており、その中の新しいコードが一部 React で書かれているという場合でも、今後は「React 内で <code class="gatsby-code-text">e.stopPropagation()</code> が呼ばれたイベントは jQuery のコードに到達しない」という（期待通りの）動作をするようになります。逆のことも言えます。もし React が好きではなくなってアプリを（例えば jQuery で）書き直したくなったとしても、イベント伝播処理を壊すことなく見た目部分を React から jQuery に移行することができるようになります。</p>
<p>この新しい挙動により、React コードと非 React コードの統合に関して <a href="https://github.com/facebook/react/issues/7094" target="_blank" rel="nofollow noopener noreferrer">過去</a> <a href="https://github.com/facebook/react/issues/8693" target="_blank" rel="nofollow noopener noreferrer">数年に</a> <a href="https://github.com/facebook/react/issues/12518" target="_blank" rel="nofollow noopener noreferrer">わたって</a> <a href="https://github.com/facebook/react/issues/13451" target="_blank" rel="nofollow noopener noreferrer">報告</a> <a href="https://github.com/facebook/react/issues/4335" target="_blank" rel="nofollow noopener noreferrer">されて</a> <a href="https://github.com/facebook/react/issues/1691" target="_blank" rel="nofollow noopener noreferrer">きた</a> <a href="https://github.com/facebook/react/issues/285#issuecomment-253502585" target="_blank" rel="nofollow noopener noreferrer">様々な</a> <a href="https://github.com/facebook/react/pull/8117" target="_blank" rel="nofollow noopener noreferrer">問題が</a> <a href="https://github.com/facebook/react/issues/11530" target="_blank" rel="nofollow noopener noreferrer">解決</a> <a href="https://github.com/facebook/react/issues/7128" target="_blank" rel="nofollow noopener noreferrer">される</a> ことが分かっています。</p>
<blockquote>
<p>補足</p>
<p>この変更によりルートコンテナ外にある<a href="/docs/portals.html">ポータル</a>の動作がおかしくなるのではと思っているかもしれません。が、React はポータルのコンテナ<strong>でも</strong>イベントをリッスンするようになるため、問題は生じません。</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>問題が出た場合の修正方法 </h4>
<p>どのような破壊的変更もそうですが、コードの一部は調整する必要があるかもしれません。Facebook では（何千ものモジュールがあるうち）合計で約 10 個のモジュールを、今回の変更に合わせて調整する必要がありました。</p>
<p>例えば <code class="gatsby-code-text">document.addEventListener(...)</code> という形で手動で DOM リスナを登録すれば、それにより React のすべてのイベントが捕捉できると期待するかもしれません。React 16 以前では、React のイベントハンドラ内で <code class="gatsby-code-text">e.stopPropagation()</code> をコールしていたとしても、<code class="gatsby-code-text">document</code> にあるあなたのカスタムのリスナはこのイベントを受け取っていました。なぜならネイティブのイベントは、ドキュメントのレベルに<strong>既に</strong>到達していたからです。React 17 以降は、イベントの伝播は（指示された通りに！）<strong>止まる</strong>ため、あなたが <code class="gatsby-code-text">document</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">// This custom handler will no longer receive clicks</span>
  <span class="token comment">// from React components that called e.stopPropagation()</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
<p>このようなコードを修正するには、イベントリスナが<a href="https://javascript.info/bubbling-and-capturing#capturing" target="_blank" rel="nofollow noopener noreferrer">キャプチャフェーズ</a>で呼ばれるようにコードを変更します。そのためには <code class="gatsby-code-text">document.addEventListener</code> の第 3 引数として <code class="gatsby-code-text">{ capture: true }</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">// Now this event handler uses the capture phase,</span>
  <span class="token comment">// so it receives *all* click events below!</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>この方針は、全体的にはむしろ障害に強くなるものだということに注意してください。この変更で、例えば、<code class="gatsby-code-text">e.stopPropagation()</code> が React イベントハンドラ外で呼ばれた場合に発生する既存のバグもおそらく修正されることでしょう。言い換えると、<strong>React 17 でのイベント伝播は普通の DOM に近くなった</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>その他の破壊的変更 </h2>
<p>React 17 での破壊的変更は最小限にとどめてあります。例えば、前のバージョンで非推奨化されたメソッドの削除は行っていません。ただし、我々の経験で比較的安全であった破壊的変更が、少数のみ含まれています。我々のコンポーネントでこれらにより修正する必要があったコンポーネントは 10 万以上あるうちの 20 未満でした。</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>ブラウザとの整合性向上 </h3>
<p>イベントシステムに幾つかの小さな変更を加えました：</p>
<ul>
<li><a href="https://github.com/facebook/react/issues/15723" target="_blank" rel="nofollow noopener noreferrer">よくある誤解</a>を防ぐため、<code class="gatsby-code-text">onScroll</code> イベントは<strong>バブリングしない</strong>ようになりました。</li>
<li>React の <code class="gatsby-code-text">onFocus</code> と <code class="gatsby-code-text">onBlur</code> イベントはネイティブの <code class="gatsby-code-text">focusin</code> と <code class="gatsby-code-text">focusout</code> イベントを裏で使うように変更されました。これらは React の既存の挙動とより合致しており、また追加の情報を有していることがあります。</li>
<li>キャプチャフェーズのイベント（<code class="gatsby-code-text">onClickCapture</code> など）は本物のブラウザのキャプチャフェーズのリスナを使うようになります。</li>
</ul>
<p>これらの変更は React の挙動をブラウザの挙動に近づけて相互運用性を改善するものです。</p>
<blockquote>
<p>補足</p>
<p>React 17 は <code class="gatsby-code-text">onFocus</code> イベント用に <code class="gatsby-code-text">focus</code> ではなく <code class="gatsby-code-text">focusin</code> を使うよう<em class="em-ja">裏で</em>変更されましたが、バブリングの挙動に影響は<strong>ない</strong>ということに注意してください。React において <code class="gatsby-code-text">onFocus</code> イベントは常にバブリングしていましたし、React 17 でも同様です。通常はこれがより有用なデフォルトの動作です。<a href="https://codesandbox.io/s/strange-albattani-7tqr7?file=/src/App.js" target="_blank" rel="nofollow noopener noreferrer">この sandbox</a> で特定のユースケースのために加えることのできるチェックについて見ることができます。</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>イベントプーリングの廃止 </h3>
<p>React 17 では「イベントプーリング」による最適化が取り除かれています。モダンブラウザではパフォーマンス向上にならず、経験のある 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">// This crashes in React 16 and earlier:</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>上記の問題が起こるのは、React が古いブラウザでのパフォーマンス改善のために複数の異なるイベント間でイベントオブジェクトを再利用しており、その際にイベントのフィールドを <code class="gatsby-code-text">null</code> にセットしていたためです。React 16 以前では、イベントを正しく使うために <code class="gatsby-code-text">e.persist()</code> を呼ぶか、本来必要になるより先にプロパティを読み出しておく必要がありました。</p>
<p><strong>React 17 では、上記のコードは本来期待される通りに動作するようになります。古いイベントプーリングによる最適化は完全に取り除かれており、必要なときにいつでもイベントのフィールドを読み出せるようになります。</strong></p>
<p>これは振る舞いの変化であるため破壊的変更としてマークしてありますが、実際上は Facebook 内でこれにより壊れたものは何もありませんでした（むしろ幾つかのバグがいつの間にか修正されたかもしれません！）。<code class="gatsby-code-text">e.persist()</code> は React イベントオブジェクト内に残りますが、今後は何もしなくなります。</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>副作用クリーンアップのタイミング </h3>
<p><code class="gatsby-code-text">useEffect</code> のクリーンアップ用関数のタイミングをより一貫性のあるものにしました。</p>
<div class="gatsby-highlight has-highlighted-lines" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token function">useEffect</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
  <span class="token comment">// This is the effect itself.</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">// This is its cleanup.</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>ほとんどの副作用は画面の更新を遅延させる必要がないので、React は副作用を画面に更新が反映された直後に非同期的に実行します（ツールチップのサイズ測定や位置合わせなど、副作用が画面の更新をブロックする必要がある稀なケースでは、<code class="gatsby-code-text">useLayoutEffect</code> を使うべきです）。</p>
<p>しかし、コンポーネントがアンマウントされる際、副作用の<em class="em-ja">クリーンアップ</em>関数の方は同期的に実行されていました（クラスコンポーネントでの <code class="gatsby-code-text">componentWillUnmount</code> が同期的であるのと同様です）。これは大きなアプリでは望ましくないということが分かりました。大きな画面遷移（タブの切り替えなど）がある場合に遅くなってしまうのです。</p>
<p><strong>React 17 では、副作用のクリーンアップ関数が常に非同期的に実行されます。例えば、コンポーネントがアンマウントされる時、クリーンアップ関数は画面が更新された<em class="em-ja">後で</em>実行されます。</strong></p>
<p>これは副作用の本体側がどのように実行されるかに合わせたものです。同期的に実行されることに依存しているような稀なケースでは、<code class="gatsby-code-text">useLayoutEffect</code> に変更することができます。</p>
<blockquote>
<p>補足</p>
<p>アンマウントされたコンポーネントにおける <code class="gatsby-code-text">setState</code> の警告を修正できなくなってしまうのではと心配されているかもしれません。心配は要りません。React はこのケースに対して特別なチェックを行っており、アンマウントとクリーンアップとの間の小さな時間帯に <code class="gatsby-code-text">setState</code> の警告を発生<em class="em-ja">させない</em>ようになっています。<strong>リクエストやインターバルをキャンセルするためのコードはほぼ常に変えずに済みます。</strong></p>
</blockquote>
<p>加えて、React 17 は（全コンポーネントにわたる）すべてのクリーンアップ関数を、新しい副作用より前に実行するようになります。React 16 ではコンポーネント内でのみこの順番が保証されているに過ぎませんでした。</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>起きる可能性のある問題 </h4>
<p>この変更により動作しなくなったコンポーネントは数個のみでしたが、再利用可能なライブラリではより注意深くテストする必要があるでしょう。問題を引き起こすコードの例は以下のようなものです：</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>問題は <code class="gatsby-code-text">someRef.current</code> は書き換え可能であるため、クリーンアップ関数が実行される段階では <code class="gatsby-code-text">null</code> に変わっている可能性がある、ということです。解決方法としては、副作用の<em class="em-ja">内部</em>で書き換わる可能性のある値をキャプチャしておきます：</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><a href="https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks" target="_blank" rel="nofollow noopener noreferrer">我々の <code class="gatsby-code-text">eslint-plugin-react-hooks/exhaustive-deps</code> lint ルール</a>（是非使うようにしましょう！）は常にこれを警告してきましたので、このような問題はあまり起きないと思います。</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>Undefined を返した場合の一貫性のあるエラー </h3>
<p>React 16 以前から、コンポーネントが <code class="gatsby-code-text">undefined</code> を返すことは常に間違いでした：</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">// Error: Nothing was returned from render</span>
<span class="token punctuation">}</span></code></pre></div>
<p>こうなっている理由の一部は、うっかり <code class="gatsby-code-text">undefined</code> を返してしまいがちだから、というものです：</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">// We forgot to write return, so this component returns undefined.</span>
  <span class="token comment">// React surfaces this as an error instead of ignoring it.</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>これまで、クラスおよび関数コンポーネントではこのチェックを行っていましたが、<code class="gatsby-code-text">forwardRef</code> と <code class="gatsby-code-text">memo</code> コンポーネントではこのような返り値のチェックを行っていませんでした。これは我々のコーディングミスによるものです。</p>
<p><strong>React 17 では、<code class="gatsby-code-text">forwardRef</code> と <code class="gatsby-code-text">memo</code> によるコンポーネントの振る舞いが通常の関数・クラスコンポーネントの振る舞いと合致するようになります。これらから <code class="gatsby-code-text">undefined</code> を返すことはエラーになります。</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">// We forgot to write return, so this component returns undefined.</span>
  <span class="token comment">// React 17 surfaces this as an error instead of ignoring it.</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">// We forgot to write return, so this component returns undefined.</span>
  <span class="token comment">// React 17 surfaces this as an error instead of ignoring it.</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>意図的に何もレンダーしたくないという場合には、<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>ネイティブのコンポーネントスタック </h3>
<p>ブラウザであなたがエラーをスローすると、ブラウザは JavaScript の関数名とそれらの位置を含んだスタックトレースを表示します。しかし、問題を診断するのに JavaScript のスタックトレースでは不十分で React ツリーの階層構造も同じくらい重要だ、ということがよくあります。<code class="gatsby-code-text">Button</code> がエラーをスローしたということだけでなく、その <code class="gatsby-code-text">Button</code> が <strong>React ツリーのどこにあるのか</strong>が知りたいでしょう。</p>
<p>この問題を解決するために React 16 で、エラーがあった場合に「コンポーネントスタック」を表示するようにしました。しかし、これはネイティブの JavaScript スタックと比べて劣ったものでした。具体的には、React はソースコード内のどこにその関数が宣言されているのか分からないため、コードをクリックすることができませんでした。また、<a href="https://github.com/facebook/react/issues/12757" target="_blank" rel="nofollow noopener noreferrer">本番モードではほぼ使いものにならない</a>という問題もありました。minify された JavaScript におけるスタックはソースマップさえあれば自動的に元の関数名に戻せますが、React コンポーネントのスタックにおいては、本番モードでも使えるようにするのかバンドルサイズを小さくするのか選ばなければいけませんでした。</p>
<p><strong>React 17 では、コンポーネントスタックの生成方法が別のメカニズムに変更され、ネイティブ JavaScript スタックと繋ぎ合わせて表示されるようになりました。これにより、本番環境においても完全に名前付きで React のコンポーネントスタックトレースを得られるようになります。</strong></p>
<p>React がこれを実装している方法はいくぶん特殊なものです。現在のところ、ブラウザは関数のスタックフレーム（ソースファイルと位置）を取得する方法を提供していません。このため、React がエラーをキャッチした場合、可能な場合は React は上流にあるコンポーネントのそれぞれから一時エラーをスロー（およびキャッチ）することでコンポーネントスタックを<em class="em-ja">再構成</em>するようになります。これによりクラッシュ時に小さなパフォーマンス低下が起きますが、コンポーネントの型につき 1 度のみです。</p>
<p>興味があれば詳細について<a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">このプルリクエスト</a>で見ることができますが、このメカニズムそのものは、ほぼあなたのコードに影響しません。開発者側から見てこの新機能が意味するのは、コンポーネントスタックをクリック可能になったということ（ネイティブのブラウザのスタックフレームに依存するようになったため）と、本番環境でもそれを普通の JavaScript エラーと同様に読めるようになった、ということです。</p>
<p>これが破壊的変更となっているのは、これを実現するために、React がエラー捕捉後にスタックの上流にある React 関数や React クラスコンストラクタのうちいくつかを再実行する必要があるからです。レンダー関数やクラスコンストラクタは副作用を持つべきではないため（これはサーバレンダリングにおいても重要です）、実際上の問題は起きないはずです。</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>プライベートなエクスポートの削除 </h3>
<p>ここで言及すべき最後の破壊的変更は、他のプロジェクトのために公開されていた React の内部構造を一部削除した、ということです。特に、<a href="https://github.com/necolas/react-native-web" target="_blank" rel="nofollow noopener noreferrer">React Native for Web</a> はイベントシステムの内部実装の一部に依存していたのですが、そのような依存は不安定であり、実際によく壊れていました。</p>
<p><strong>React 17 では、このようなプライベートなエクスポートが削除されています。我々の知る限り、React Native for Web がそれを使っていた唯一のプロジェクトであり、既にプライベートなエクスポートに依存しない別の手法にコードの移行を完了しています。</strong></p>
<p>つまり React Native for Web の古いバージョンは React 17 で動作せず、新しいバージョンのみが動作するということです。実際には、React 内部の実装の変化に対応するため React Native for Web は何にせよ新バージョンをリリースする必要があった訳で、大きく話が変わるものではないでしょう。</p>
<p>加えて、<code class="gatsby-code-text">ReactTestUtils.SimulateNative</code> ヘルパメソッドも削除しています。これはドキュメントされたこともなく、名前から期待される通りの動作をしたこともなく、イベントシステムに我々が加えた変更によりうまく動作しなくなりました。テストでネイティブのブラウザイベントを発生させる便利な方法が欲しい場合は、代わりに <a href="https://testing-library.com/docs/dom-testing-library/api-events" target="_blank" rel="nofollow noopener noreferrer">React Testing Library</a> をチェックしてください。</p>
<h2 id="installation"><a href="#installation" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>インストール </h2>
<p>React 17.0 リリース候補を試してみて、移行作業中に遭遇する問題について <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer">issue を報告</a>してください。<strong>リリース候補版は安定リリースと比べてバグがある可能性が高いため、本番環境への投入はまだしないでください</strong>。</p>
<p>React 17 RC を npm でインストールするには以下のようにします：</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>React 17 RC を 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@17.0.0-rc.3 react-dom@17.0.0-rc.3</code></pre></div>
<p>CDN 経由で React の UMD ビルドも提供しています：</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><a href="/docs/installation.html">詳細なインストール手順</a>についてはドキュメントを参照してください。</p>
<h2 id="changelog"><a href="#changelog" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changelog </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<ul>
<li>Add <code class="gatsby-code-text">react/jsx-runtime</code> and <code class="gatsby-code-text">react/jsx-dev-runtime</code> for the <a href="https://babeljs.io/blog/2020/03/16/7.9.0#a-new-jsx-transform-11154-https-githubcom-babel-babel-pull-11154" target="_blank" rel="nofollow noopener noreferrer">new JSX transform</a>. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> in <a href="https://github.com/facebook/react/pull/18299" target="_blank" rel="nofollow noopener noreferrer">#18299</a>)</li>
<li>Build component stacks from native error frames. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18561" target="_blank" rel="nofollow noopener noreferrer">#18561</a>)</li>
<li>Allow to specify <code class="gatsby-code-text">displayName</code> on context for improved stacks. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18224" target="_blank" rel="nofollow noopener noreferrer">#18224</a>)</li>
<li>Prevent <code class="gatsby-code-text">'use strict'</code> from leaking in the UMD bundles. (<a href="https://github.com/koba04" target="_blank" rel="nofollow noopener noreferrer">@koba04</a> in <a href="https://github.com/facebook/react/pull/19614" target="_blank" rel="nofollow noopener noreferrer">#19614</a>)</li>
<li>Stop using <code class="gatsby-code-text">fb.me</code> for redirects. (<a href="https://github.com/cylim" target="_blank" rel="nofollow noopener noreferrer">@cylim</a> in <a href="https://github.com/facebook/react/pull/19598" target="_blank" rel="nofollow noopener noreferrer">#19598</a>)</li>
</ul>
<h3 id="react-dom"><a href="#react-dom" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM </h3>
<ul>
<li>Delegate events to roots instead of <code class="gatsby-code-text">document</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18195" target="_blank" rel="nofollow noopener noreferrer">#18195</a> and <a href="https://github.com/facebook/react/pulls?q=is%3Apr+author%3Atrueadm+modern+event+is%3Amerged" target="_blank" rel="nofollow noopener noreferrer">others</a>)</li>
<li>Clean up all effects before running any next effects. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17947" target="_blank" rel="nofollow noopener noreferrer">#17947</a>)</li>
<li>Run <code class="gatsby-code-text">useEffect</code> cleanup functions asynchronously. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17925" target="_blank" rel="nofollow noopener noreferrer">#17925</a>)</li>
<li>Use browser <code class="gatsby-code-text">focusin</code> and <code class="gatsby-code-text">focusout</code> for <code class="gatsby-code-text">onFocus</code> and <code class="gatsby-code-text">onBlur</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/19186" target="_blank" rel="nofollow noopener noreferrer">#19186</a>)</li>
<li>Make all <code class="gatsby-code-text">Capture</code> events use the browser capture phase. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/19221" target="_blank" rel="nofollow noopener noreferrer">#19221</a>)</li>
<li>Don’t emulate bubbling of the <code class="gatsby-code-text">onScroll</code> event. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19464" target="_blank" rel="nofollow noopener noreferrer">#19464</a>)</li>
<li>Throw if <code class="gatsby-code-text">forwardRef</code> or <code class="gatsby-code-text">memo</code> component returns <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Remove event pooling. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18969" target="_blank" rel="nofollow noopener noreferrer">#18969</a>)</li>
<li>Stop exposing internals that won’t be needed by React Native Web. (<a href="https://github.com/necolas" target="_blank" rel="nofollow noopener noreferrer">@necolas</a> in <a href="https://github.com/facebook/react/pull/18483" target="_blank" rel="nofollow noopener noreferrer">#18483</a>)</li>
<li>Attach all known event listeners when the root mounts. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19659" target="_blank" rel="nofollow noopener noreferrer">#19659</a>)</li>
<li>Disable <code class="gatsby-code-text">console</code> in the second render pass of DEV mode double render. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>Deprecate the undocumented and misleading <code class="gatsby-code-text">ReactTestUtils.SimulateNative</code> API. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/13407" target="_blank" rel="nofollow noopener noreferrer">#13407</a>)</li>
<li>Rename private field names used in the internals. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/18377" target="_blank" rel="nofollow noopener noreferrer">#18377</a>)</li>
<li>Don’t call User Timing API in development. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/18417" target="_blank" rel="nofollow noopener noreferrer">#18417</a>)</li>
<li>Disable console during the repeated render in Strict Mode. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18547" target="_blank" rel="nofollow noopener noreferrer">#18547</a>)</li>
<li>In Strict Mode, double-render components without Hooks too. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18430" target="_blank" rel="nofollow noopener noreferrer">#18430</a>)</li>
<li>Allow calling <code class="gatsby-code-text">ReactDOM.flushSync</code> during lifecycle methods (but warn). (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18759" target="_blank" rel="nofollow noopener noreferrer">#18759</a>)</li>
<li>Add the <code class="gatsby-code-text">code</code> property to the keyboard event objects. (<a href="https://github.com/bl00mber" target="_blank" rel="nofollow noopener noreferrer">@bl00mber</a> in <a href="https://github.com/facebook/react/pull/18287" target="_blank" rel="nofollow noopener noreferrer">#18287</a>)</li>
<li>Add the <code class="gatsby-code-text">disableRemotePlayback</code> property for <code class="gatsby-code-text">video</code> elements. (<a href="https://github.com/tombrowndev" target="_blank" rel="nofollow noopener noreferrer">@tombrowndev</a> in <a href="https://github.com/facebook/react/pull/18619" target="_blank" rel="nofollow noopener noreferrer">#18619</a>)</li>
<li>Add the <code class="gatsby-code-text">enterKeyHint</code> property for <code class="gatsby-code-text">input</code> elements. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18634" target="_blank" rel="nofollow noopener noreferrer">#18634</a>)</li>
<li>Warn when no <code class="gatsby-code-text">value</code> is provided to <code class="gatsby-code-text">&lt;Context.Provider></code>. (<a href="https://github.com/charlie1404" target="_blank" rel="nofollow noopener noreferrer">@charlie1404</a> in <a href="https://github.com/facebook/react/pull/19054" target="_blank" rel="nofollow noopener noreferrer">#19054</a>)</li>
<li>Warn when <code class="gatsby-code-text">memo</code> or <code class="gatsby-code-text">forwardRef</code> components return <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/19550" target="_blank" rel="nofollow noopener noreferrer">#19550</a>)</li>
<li>Improve the error message for invalid updates. (<a href="https://github.com/JoviDeCroock" target="_blank" rel="nofollow noopener noreferrer">@JoviDeCroock</a> in <a href="https://github.com/facebook/react/pull/18316" target="_blank" rel="nofollow noopener noreferrer">#18316</a>)</li>
<li>Exclude forwardRef and memo from stack frames. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18559" target="_blank" rel="nofollow noopener noreferrer">#18559</a>)</li>
<li>Improve the error message when switching between controlled and uncontrolled inputs. (<a href="https://github.com/vcarl" target="_blank" rel="nofollow noopener noreferrer">@vcarl</a> in <a href="https://github.com/facebook/react/pull/17070" target="_blank" rel="nofollow noopener noreferrer">#17070</a>)</li>
<li>Keep <code class="gatsby-code-text">onTouchStart</code>, <code class="gatsby-code-text">onTouchMove</code>, and <code class="gatsby-code-text">onWheel</code> passive. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19654" target="_blank" rel="nofollow noopener noreferrer">#19654</a>)</li>
<li>Fix <code class="gatsby-code-text">setState</code> hanging in development inside a closed iframe. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19220" target="_blank" rel="nofollow noopener noreferrer">#19220</a>)</li>
<li>Fix rendering bailout for lazy components with <code class="gatsby-code-text">defaultProps</code>. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> in <a href="https://github.com/facebook/react/pull/18539" target="_blank" rel="nofollow noopener noreferrer">#18539</a>)</li>
<li>Fix a false positive warning when <code class="gatsby-code-text">dangerouslySetInnerHTML</code> is <code class="gatsby-code-text">undefined</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/18676" target="_blank" rel="nofollow noopener noreferrer">#18676</a>)</li>
<li>Fix Test Utils with non-standard <code class="gatsby-code-text">require</code> implementation. (<a href="https://github.com/just-boris" target="_blank" rel="nofollow noopener noreferrer">@just-boris</a> in <a href="https://github.com/facebook/react/pull/18632" target="_blank" rel="nofollow noopener noreferrer">#18632</a>)</li>
<li>Fix <code class="gatsby-code-text">onBeforeInput</code> reporting an incorrect <code class="gatsby-code-text">event.type</code>. (<a href="https://github.com/eps1lon" target="_blank" rel="nofollow noopener noreferrer">@eps1lon</a> in <a href="https://github.com/facebook/react/pull/19561" target="_blank" rel="nofollow noopener noreferrer">#19561</a>)</li>
<li>Fix <code class="gatsby-code-text">event.relatedTarget</code> reported as <code class="gatsby-code-text">undefined</code> in Firefox. (<a href="https://github.com/claytercek" target="_blank" rel="nofollow noopener noreferrer">@claytercek</a> in <a href="https://github.com/facebook/react/pull/19607" target="_blank" rel="nofollow noopener noreferrer">#19607</a>)</li>
<li>Fix “unspecified error” in IE11. (<a href="https://github.com/hemakshis" target="_blank" rel="nofollow noopener noreferrer">@hemakshis</a> in <a href="https://github.com/facebook/react/pull/19664" target="_blank" rel="nofollow noopener noreferrer">#19664</a>)</li>
<li>Fix rendering into a shadow root. (<a href="https://github.com/Jack-Works" target="_blank" rel="nofollow noopener noreferrer">@Jack-Works</a> in <a href="https://github.com/facebook/react/pull/15894" target="_blank" rel="nofollow noopener noreferrer">#15894</a>)</li>
<li>Fix <code class="gatsby-code-text">movementX/Y</code> polyfill with capture events. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19672" target="_blank" rel="nofollow noopener noreferrer">#19672</a>)</li>
<li>Use delegation for <code class="gatsby-code-text">onSubmit</code> and <code class="gatsby-code-text">onReset</code> events. (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/19333" target="_blank" rel="nofollow noopener noreferrer">#19333</a>)</li>
<li>Improve memory usage. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18970" target="_blank" rel="nofollow noopener noreferrer">#18970</a>)</li>
</ul>
<h3 id="react-dom-server"><a href="#react-dom-server" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React DOM Server </h3>
<ul>
<li>Make <code class="gatsby-code-text">useCallback</code> behavior consistent with <code class="gatsby-code-text">useMemo</code> for the server renderer. (<a href="https://github.com/alexmckenley" target="_blank" rel="nofollow noopener noreferrer">@alexmckenley</a> in <a href="https://github.com/facebook/react/pull/18783" target="_blank" rel="nofollow noopener noreferrer">#18783</a>)</li>
<li>Fix state leaking when a function component throws. (<a href="https://github.com/pmaccart" target="_blank" rel="nofollow noopener noreferrer">@pmaccart</a> in <a href="https://github.com/facebook/react/pull/19212" target="_blank" rel="nofollow noopener noreferrer">#19212</a>)</li>
</ul>
<h3 id="react-test-renderer"><a href="#react-test-renderer" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React Test Renderer </h3>
<ul>
<li>Improve <code class="gatsby-code-text">findByType</code> error message. (<a href="https://github.com/henryqdineen" target="_blank" rel="nofollow noopener noreferrer">@henryqdineen</a> in <a href="https://github.com/facebook/react/pull/17439" target="_blank" rel="nofollow noopener noreferrer">#17439</a>)</li>
</ul>
<h3 id="concurrent-mode-experimental"><a href="#concurrent-mode-experimental" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Concurrent Mode (Experimental) </h3>
<ul>
<li>Revamp the priority batching heuristics. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18796" target="_blank" rel="nofollow noopener noreferrer">#18796</a>)</li>
<li>Add the <code class="gatsby-code-text">unstable_</code> prefix before the experimental APIs. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remove <code class="gatsby-code-text">unstable_discreteUpdates</code> and <code class="gatsby-code-text">unstable_flushDiscreteUpdates</code>. (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/18825" target="_blank" rel="nofollow noopener noreferrer">#18825</a>)</li>
<li>Remove the <code class="gatsby-code-text">timeoutMs</code> argument. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/19703" target="_blank" rel="nofollow noopener noreferrer">#19703</a>)</li>
<li>Disable <code class="gatsby-code-text">&lt;div hidden /></code> prerendering in favor of a different future API. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18917" target="_blank" rel="nofollow noopener noreferrer">#18917</a>)</li>
<li>Add <code class="gatsby-code-text">unstable_expectedLoadTime</code> to Suspense for CPU-bound trees. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/19936" target="_blank" rel="nofollow noopener noreferrer">#19936</a>)</li>
<li>Add an experimental <code class="gatsby-code-text">unstable_useOpaqueIdentifier</code> Hook. (<a href="https://github.com/lunaruan" target="_blank" rel="nofollow noopener noreferrer">@lunaruan</a> in <a href="https://github.com/facebook/react/pull/17322" target="_blank" rel="nofollow noopener noreferrer">#17322</a>)</li>
<li>Add an experimental <code class="gatsby-code-text">unstable_startTransition</code> API. (<a href="https://github.com/rickhanlonii" target="_blank" rel="nofollow noopener noreferrer">@rickhanlonii</a> in <a href="https://github.com/facebook/react/pull/19696" target="_blank" rel="nofollow noopener noreferrer">#19696</a>)</li>
<li>Using <code class="gatsby-code-text">act</code> in the test renderer no longer flushes Suspense fallbacks. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18596" target="_blank" rel="nofollow noopener noreferrer">#18596</a>)</li>
<li>Use global render timeout for CPU Suspense. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/19643" target="_blank" rel="nofollow noopener noreferrer">#19643</a>)</li>
<li>Clear the existing root content before mounting. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18730" target="_blank" rel="nofollow noopener noreferrer">#18730</a>)</li>
<li>Fix a bug with error boundaries. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18265" target="_blank" rel="nofollow noopener noreferrer">#18265</a>)</li>
<li>Fix a bug causing dropped updates in a suspended tree. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18384" target="_blank" rel="nofollow noopener noreferrer">#18384</a> and <a href="https://github.com/facebook/react/pull/18457" target="_blank" rel="nofollow noopener noreferrer">#18457</a>)</li>
<li>Fix a bug causing dropped render phase updates. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18537" target="_blank" rel="nofollow noopener noreferrer">#18537</a>)</li>
<li>Fix a bug in SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18412" target="_blank" rel="nofollow noopener noreferrer">#18412</a>)</li>
<li>Fix a bug causing Suspense fallback to show too early. (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18411" target="_blank" rel="nofollow noopener noreferrer">#18411</a>)</li>
<li>Fix a bug with class components inside SuspenseList. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18448" target="_blank" rel="nofollow noopener noreferrer">#18448</a>)</li>
<li>Fix a bug with inputs that may cause updates to be dropped. (<a href="https://github.com/jddxf" target="_blank" rel="nofollow noopener noreferrer">@jddxf</a> in <a href="https://github.com/facebook/react/pull/18515" target="_blank" rel="nofollow noopener noreferrer">#18515</a> and <a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18535" target="_blank" rel="nofollow noopener noreferrer">#18535</a>)</li>
<li>Fix a bug causing Suspense fallback to get stuck.  (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18663" target="_blank" rel="nofollow noopener noreferrer">#18663</a>)</li>
<li>Don’t cut off the tail of a SuspenseList if hydrating. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18854" target="_blank" rel="nofollow noopener noreferrer">#18854</a>)</li>
<li>Fix a bug in <code class="gatsby-code-text">useMutableSource</code> that may happen when <code class="gatsby-code-text">getSnapshot</code> changes. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18297" target="_blank" rel="nofollow noopener noreferrer">#18297</a>)</li>
<li>Fix a tearing bug in <code class="gatsby-code-text">useMutableSource</code>. (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/18912" target="_blank" rel="nofollow noopener noreferrer">#18912</a>)</li>
<li>Warn if calling setState outside of render but before commit. (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/18838" target="_blank" rel="nofollow noopener noreferrer">#18838</a>)</li>
</ul>]]></description><link>https://ja.reactjs.org/blog/2020/08/10/react-v17-rc.html</link><guid isPermaLink="false">https://ja.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>このブログはアーカイブされています。最新の記事は <a href="https://ja.react.dev/blog" target="_blank" rel="nofollow noopener noreferrer">ja.react.dev/blog</a> でご覧ください。</p>
</blockquote>
</div>
<p>本日、React 16.13.0 をリリースします。このリリースには、バグ修正と、今後のメジャーリリースに備えるための新しい非推奨の警告が含まれています。</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>新たな警告 </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>レンダー中のいくつかの更新に関する警告 </h3>
<p>React コンポーネントは、レンダー中に他のコンポーネントに副作用を起こしてはいけません。</p>
<p>レンダー中に <code class="gatsby-code-text">setState</code> を呼び出すことはサポートされていますが<a href="/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops"><em class="em-ja">同じ</em>コンポーネントに対してのみ</a>可能です。別のコンポーネントのレンダー中に <code class="gatsby-code-text">setState</code> を呼び出すと、警告が表示されるようになりました。</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>この警告は、意図しない状態変更によって引き起こされるアプリケーションのバグを見つけるのに役立ちます。</strong>レンダーの結果として他のコンポーネントの状態を意図的に変更したいという稀なケースでは、<code class="gatsby-code-text">setState</code> 呼び出しを <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>スタイルルールが矛盾している場合の警告 </h3>
<p>ある CSS プロパティの長い記法と短い記法を同時に含む <code class="gatsby-code-text">style</code> を動的に適用する場合、特定の更新の組み合わせにより、スタイリングの一貫性が失われることがあります。例えば、以下のようになります。</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>この <code class="gatsby-code-text">&lt;div></code> は <code class="gatsby-code-text">toggle</code> の値に関係なく常に背景色が赤になると思われるかもしれません。しかし、<a href="https://codesandbox.io/s/serene-dijkstra-dr0vev" target="_blank" rel="nofollow noopener noreferrer">このデモを見てわかるように</a>、<code class="gatsby-code-text">toggle</code> の値を <code class="gatsby-code-text">true</code> と <code class="gatsby-code-text">false</code> の間で切り替えると、背景色は <code class="gatsby-code-text">red</code> から始まり、その後 <code class="gatsby-code-text">transparent</code> と <code class="gatsby-code-text">blue</code> の間で交互に切り替わります。</p>
<p><strong>React は、スタイルルールの競合を検出し、警告をログに記録するようになりました。</strong>この問題を修正するには、同一の CSS プロパティの短い記法と長い記法のバージョンを <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>一部の非推奨 string ref に関する注意点 </h3>
<p><a href="/docs/refs-and-the-dom.html#legacy-api-string-refs">String ref（文字列形式の ref）は古いレガシー API</a> であり、既に勧められておらず、将来的に正式に非推奨となる予定です。</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>（String ref と異なり、一般的な ref 自体は<strong>完全にサポートされ続けます</strong>ので混同しないようにしてください）</p>
<p>将来的には、string ref からの移行を自動化するスクリプト (“codemod”) を提供する予定です。しかし、まれに自動移行できないケースがあります。このリリースでは、非推奨化に先立ち、<strong>そのようなケースにのみ</strong>警告を追加しています。</p>
<p>例えば、レンダープロップパターンと一緒に string ref を使用した場合に発生します。</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>このようなコードはしばしばバグを示します（ref は <code class="gatsby-code-text">ClassParent</code> で利用できると思われるかもしれませんが、代わりに <code class="gatsby-code-text">ClassWithRenderProp</code> に置かれてしまいます）。</p>
<p><strong>このようなコードはお持ちでない可能性が高いでしょう</strong>。もしそのようなコードがあって、それが意図的なものであれば、代わりに <a href="/docs/refs-and-the-dom.html#creating-refs"><code class="gatsby-code-text">React.createRef()</code></a> を使うよう変更してください：</p>
<div class="gatsby-highlight" data-language="jsx"><pre class="gatsby-code-jsx"><code class="gatsby-code-jsx"><span class="token keyword">class</span> <span class="token class-name">ClassWithRenderProp</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>
  myRef <span class="token operator">=</span> React<span class="token punctuation">.</span><span class="token function">createRef</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token function">componentDidMount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">doSomething</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>myRef<span class="token punctuation">.</span>current<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>props<span class="token punctuation">.</span><span class="token function">children</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>myRef<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">ClassParent</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>
  <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token punctuation">(</span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">ClassWithRenderProp</span></span><span class="token punctuation">></span></span><span class="token plain-text">
        </span><span class="token punctuation">{</span><span class="token parameter">myRef</span> <span class="token operator">=></span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">ref</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>myRef<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">}</span><span class="token plain-text">
      </span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">ClassWithRenderProp</span></span><span class="token punctuation">></span></span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre></div>
<blockquote>
<p>補足</p>
<p>この警告を見るためには、Babel プラグインとして <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> がインストールされている必要があります。これは開発モードで<em class="em-ja">のみ</em>有効にする必要があります。</p>
<p>Create React App を使っているか、Babel 7 以降で “react” プリセットを使っている場合、既にデフォルトでこのプラグインはインストールされています。</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><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> は React 要素を作成するためのレガシーのヘルパです。このリリースでは、このメソッドに非推奨の警告が追加されています。これは将来のメジャーバージョンで削除される予定です。</p>
<p><code class="gatsby-code-text">React.createFactory</code> の使用法を通常の JSX で置き換えてください。代わりに、この 1 行ヘルパをコピー＆ペーストするか、ライブラリとして公開することもできます。</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>全く同じことをしています。</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><code class="gatsby-code-text">ReactDOM.unstable_createPortal</code> の非推奨化、<code class="gatsby-code-text">ReactDOM.createPortal</code> に変更を </h3>
<p>React 16 がリリースされたとき、<code class="gatsby-code-text">createPortal</code> は公式にサポートされる API になりました。</p>
<p>しかし、<code class="gatsby-code-text">unstable_createPortal</code> を採用している少数のライブラリが動作するように、<code class="gatsby-code-text">unstable_createPortal</code> をサポートされたエイリアスとして残していました。今後この不安定なエイリアスは非推奨とします。<code class="gatsby-code-text">unstable_createPortal</code> の代わりに <code class="gatsby-code-text">createPortal</code> を直接使ってください。これは全く同じシグネチャを持っています。</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>その他の改良事項 </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>hydration の警告におけるコンポーネントスタック </h3>
<p>React は開発者向け警告にコンポーネントスタックを追加し、開発者がバグを特定してプログラムをデバッグできるようにしています。今回のリリースでは、以前はコンポーネントスタックが存在しなかった多くの開発者向け警告に、それが追加されました。例として、以前のバージョンにあったこのハイドレーション警告を考えてみましょう。</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="A screenshot of the console warning, simply stating the nature of the hydration mismatch: "Warning: Expected server HTML to contain a matching div in 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>コードとともにエラーを指摘していますが、どこにエラーが存在しているのか、次に何をすればいいのかが明確ではありません。このリリースでは、この警告にコンポーネントスタックが追加され、以下のようになりました。</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="A screenshot of the console warning, stating the nature of the hydration mismatch, but also including a component stack : "Warning: Expected server HTML to contain a matching div in div, in div (at 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>これにより、問題がどこにあるのかが明確になり、より早くバグの場所を特定して修正することができます。</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>注目すべきバグ修正 </h3>
<p>このリリースには、他にもいくつかの注目すべき改善点が含まれています。</p>
<ul>
<li>Strict 開発モードでは、React はライフサイクルメソッドを 2 回呼び出し、好ましくない副作用の可能性を洗い出すようにしています。このリリースでは、その動作を <code class="gatsby-code-text">shouldComponentUpdate</code> に追加しています。これは、<code class="gatsby-code-text">shouldComponentUpdate</code> に副作用がない限り、ほとんどのコードには影響しないはずです。これを修正するには、副作用のあるコードを <code class="gatsby-code-text">componentDidUpdate</code> に移動してください。</li>
<li>Strict 開発モードでは、レガシーコンテクスト API の使用に関する警告には、警告のトリガとなったコンポーネントのスタックが含まれていませんでした。このリリースでは、欠けていたスタックが警告に追加されます。</li>
<li>無効な（disabled の）<code class="gatsby-code-text">&lt;button></code> 要素に対して <code class="gatsby-code-text">onMouseEnter</code> がトリガされないようになりました。</li>
<li>ReactDOM は v16 を公開して以来、<code class="gatsby-code-text">version</code> のエクスポートがありませんでした。このリリースではそれが改めて追加されました。アプリケーションロジックでの使用はお勧めしませんが、同じページ上の ReactDOM のバージョン不一致や複数バージョンに関わる問題をデバッグする際に便利です。</li>
</ul>
<p>これらの問題やその他の問題を解決してくれた貢献者に感謝します。完全な changelog は<a href="#changelog">下記</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>インストール </h2>
<h3 id="react"><a href="#react" aria-hidden class="anchor"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>React </h3>
<p>React v16.13.0 は npm レジストリで利用可能です。</p>
<p>Yarn で React 16 をインストールするには、下記を実行します：</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>npm で React 16 をインストールするには、下記を実行します：</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>また、CDN 経由で React の UMD ビルドも提供しています：</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><a href="/docs/installation.html">詳細なインストール方法</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>変更履歴 </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>Warn when a string ref is used in a manner that’s not amenable to a future 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>Deprecate <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>Warn when changes in <code class="gatsby-code-text">style</code> may cause an unexpected collision (<a href="https://github.com/sophiebits" target="_blank" rel="nofollow noopener noreferrer">@sophiebits</a> in <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>Warn when a function component is updated during another component’s render phase (<a href="(https://github.com/acdlite)">@acdlite</a> in <a href="https://github.com/facebook/react/pull/17099" target="_blank" rel="nofollow noopener noreferrer">#17099</a>)</li>
<li>Deprecate <code class="gatsby-code-text">unstable_createPortal</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/17880" target="_blank" rel="nofollow noopener noreferrer">#17880</a>)</li>
<li>Fix <code class="gatsby-code-text">onMouseEnter</code> being fired on disabled buttons (<a href="https://github.com/AlfredoGJ" target="_blank" rel="nofollow noopener noreferrer">@AlfredoGJ</a> in <a href="https://github.com/facebook/react/pull/17675" target="_blank" rel="nofollow noopener noreferrer">#17675</a>)</li>
<li>Call <code class="gatsby-code-text">shouldComponentUpdate</code> twice when developing in <code class="gatsby-code-text">StrictMode</code> (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17942" target="_blank" rel="nofollow noopener noreferrer">#17942</a>)</li>
<li>Add <code class="gatsby-code-text">version</code> property to ReactDOM (<a href="https://github.com/ealush" target="_blank" rel="nofollow noopener noreferrer">@ealush</a> in <a href="https://github.com/facebook/react/pull/15780" target="_blank" rel="nofollow noopener noreferrer">#15780</a>)</li>
<li>Don’t call <code class="gatsby-code-text">toString()</code> of <code class="gatsby-code-text">dangerouslySetInnerHTML</code> (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/17773" target="_blank" rel="nofollow noopener noreferrer">#17773</a>)</li>
<li>Show component stacks in more warnings (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <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>Concurrent Mode (Experimental) </h3>
<ul>
<li>Warn for problematic usages of <code class="gatsby-code-text">ReactDOM.createRoot()</code> (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/17937" target="_blank" rel="nofollow noopener noreferrer">#17937</a>)</li>
<li>Remove <code class="gatsby-code-text">ReactDOM.createRoot()</code> callback params and added warnings on usage (<a href="https://github.com/bvaughn" target="_blank" rel="nofollow noopener noreferrer">@bvaughn</a> in <a href="https://github.com/facebook/react/pull/17916" target="_blank" rel="nofollow noopener noreferrer">#17916</a>)</li>
<li>Don’t group Idle/Offscreen work with other work (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/17456" target="_blank" rel="nofollow noopener noreferrer">#17456</a>)</li>
<li>Adjust <code class="gatsby-code-text">SuspenseList</code> CPU bound heuristic (<a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <a href="https://github.com/facebook/react/pull/17455" target="_blank" rel="nofollow noopener noreferrer">#17455</a>)</li>
<li>Add missing event plugin priorities (<a href="https://github.com/trueadm" target="_blank" rel="nofollow noopener noreferrer">@trueadm</a> in <a href="https://github.com/facebook/react/pull/17914" target="_blank" rel="nofollow noopener noreferrer">#17914</a>)</li>
<li>Fix <code class="gatsby-code-text">isPending</code> only being true when transitioning from inside an input event (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/17382" target="_blank" rel="nofollow noopener noreferrer">#17382</a>)</li>
<li>Fix <code class="gatsby-code-text">React.memo</code> components dropping updates when interrupted by a higher priority update (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> in <a href="https://github.com/facebook/react/pull/18091" target="_blank" rel="nofollow noopener noreferrer">#18091</a>)</li>
<li>Don’t warn when suspending at the wrong priority (<a href="https://github.com/gaearon" target="_blank" rel="nofollow noopener noreferrer">@gaearon</a> in <a href="https://github.com/facebook/react/pull/17971" target="_blank" rel="nofollow noopener noreferrer">#17971</a>)</li>
<li>Fix a bug with rebasing updates (<a href="https://github.com/acdlite" target="_blank" rel="nofollow noopener noreferrer">@acdlite</a> and <a href="https://github.com/sebmarkbage" target="_blank" rel="nofollow noopener noreferrer">@sebmarkbage</a> in <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://ja.reactjs.org/blog/2020/02/26/react-v16.13.0.html</link><guid isPermaLink="false">https://ja.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>