{"componentChunkName":"component---src-templates-docs-js","path":"/docs/codebase-overview.html","result":{"data":{"markdownRemark":{"html":"<p>このセクションでは React コードベースの構成や規則そして実装についての概要を説明します。</p>\n<p>あなたが <a href=\"/docs/how-to-contribute.html\">React にコントリビュート</a>したい場合に、このガイドがあなたがより快適に変更を行えるように手助けとなる事を願っています。</p>\n<p>これらの規約のいずれかをあなたの React アプリケーションで推奨しているというわけでは必ずしもありません。規約の多くは歴史的な理由で存在しており、時間とともに変化する可能性があります。</p>\n<h3 id=\"top-level-folders\"><a href=\"#top-level-folders\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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>\n<p><a href=\"https://github.com/facebook/react\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React リポジトリ</a>をクローンした後、プロジェクトのルートディレクトリに複数のフォルダがあることに気がつくでしょう：</p>\n<ul>\n<li><a href=\"https://github.com/facebook/react/tree/main/packages\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">packages</code></a> には React リポジトリの全てのパッケージのメタデータ（<code class=\"gatsby-code-text\">package.json</code> など）や、ソースコード（<code class=\"gatsby-code-text\">src</code> サブディレクトリ）が含まれています。<strong>あなたの変更がコードに関するものなら、各パッケージの <code class=\"gatsby-code-text\">src</code> サブディレクトリが作業時間のほとんどを過ごす場所となります</strong>。</li>\n<li><a href=\"https://github.com/facebook/react/tree/main/fixtures\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">fixtures</code></a> にはコントリビューター向けの React の小さなテスト用アプリケーションが含まれています。</li>\n<li><code class=\"gatsby-code-text\">build</code> は React のビルド出力です。リポジトリには存在しませんが、最初に <a href=\"/docs/how-to-contribute.html#development-workflow\">React をビルドした</a>後に clone した React ディレクトリに現れます。</li>\n</ul>\n<p>ドキュメントは <a href=\"https://github.com/reactjs/reactjs.org\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React 本体とは異なるリポジトリ</a>にホスティングされています。</p>\n<p>他にも最上位にあるフォルダがありますが、ほとんどはツールが使用するためのもので、コントリビュートする場合にそれらに直面することはほぼありません。</p>\n<h3 id=\"colocated-tests\"><a href=\"#colocated-tests\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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>\n<p>ユニットテスト用の最上位ディレクトリはありません。代わりに、テスト対象のファイルのすぐ隣の <code class=\"gatsby-code-text\">__tests__</code> というディレクトリに置いています。</p>\n<p>例えば、<a href=\"https://github.com/facebook/react/blob/87724bd87506325fcaf2648c70fc1f43411a87be/src/renderers/dom/client/utils/setInnerHTML.js\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">setInnerHTML.js</code></a> のテストは、すぐ隣の <a href=\"https://github.com/facebook/react/blob/87724bd87506325fcaf2648c70fc1f43411a87be/src/renderers/dom/client/utils/__tests__/setInnerHTML-test.js\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">__tests__/setInnerHTML-test.js</code></a> にあります。</p>\n<h3 id=\"warnings-and-invariants\"><a href=\"#warnings-and-invariants\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>警告と不変数 (Invariant) </h3>\n<p>React のコードベースは警告の表示に <code class=\"gatsby-code-text\">console.error</code> を使用しています：</p>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>__DEV__<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Something is wrong.'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>警告は開発時にのみ有効になります。本番時には警告は完全に取り除かれます。コードの一部の実行を禁止する必要がある場合は、代わりに <code class=\"gatsby-code-text\">invariant</code> モジュールを使用してください：</p>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token keyword\">var</span> invariant <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'invariant'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token function\">invariant</span><span class=\"token punctuation\">(</span>\n  <span class=\"token number\">2</span> <span class=\"token operator\">+</span> <span class=\"token number\">2</span> <span class=\"token operator\">===</span> <span class=\"token number\">4</span><span class=\"token punctuation\">,</span>\n  <span class=\"token string\">'You shall not pass!'</span>\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p><strong>invariant は <code class=\"gatsby-code-text\">invariant</code> 内の条件が <code class=\"gatsby-code-text\">false</code> のときスローされます。</strong></p>\n<p>“Invariant” とは “この条件は常に true である” ということの単なる言い換えです。アサーションを作成していると考えることができます。</p>\n<p>開発バージョンと本番バージョンで同じ動作となるようにしておく事は重要ですので、<code class=\"gatsby-code-text\">invariant</code> は両方の環境でスローされます。本番バージョンではエラーメッセージは自動的にエラーコードに変換され、バイト数に悪影響が出ることを避けます。</p>\n<h3 id=\"development-and-production\"><a href=\"#development-and-production\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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>\n<p>コードベース内で <code class=\"gatsby-code-text\">__DEV__</code> 擬似グローバル変数を使用して、開発用のコードブロックを保護することができます。</p>\n<p>コンパイル時にインライン化され、CommonJS のビルド時には <code class=\"gatsby-code-text\">process.env.NODE_ENV !== 'production'</code> というチェックに変換されます。</p>\n<p>スタンドアロンなビルドにおいては、minify されないビルドでは <code class=\"gatsby-code-text\">true</code> となり、minify されたビルドではそれを囲む <code class=\"gatsby-code-text\">if</code> ブロックごと完全に除去されます。</p>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>__DEV__<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token comment\">// This code will only run in development.</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<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>\n<p>最近私たちはコードベースに <a href=\"https://flow.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Flow</a> によるチェックを導入し始めました。ライセンスヘッダで <code class=\"gatsby-code-text\">@flow</code> アノテーションがマークされているファイルは型チェックをされています。</p>\n<p><a href=\"https://github.com/facebook/react/pull/7600/files\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">既存のコードに Flow アノテーションを追加する</a>プルリクエストを受けつけています。Flow アノテーションは以下のようになります：</p>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\">ReactRef<span class=\"token punctuation\">.</span><span class=\"token function-variable function\">detachRefs</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span>\n  <span class=\"token parameter\"><span class=\"token literal-property property\">instance</span><span class=\"token operator\">:</span> ReactInstance<span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">element</span><span class=\"token operator\">:</span> ReactElement <span class=\"token operator\">|</span> string <span class=\"token operator\">|</span> number <span class=\"token operator\">|</span> <span class=\"token keyword\">null</span> <span class=\"token operator\">|</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span></span>\n<span class=\"token punctuation\">)</span><span class=\"token operator\">:</span> <span class=\"token keyword\">void</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token comment\">// ...</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>可能であれば、新しいコードは Flow アノテーションを使うべきです。\n<code class=\"gatsby-code-text\">yarn flow</code> を実行することでローカル環境で Flow を使ってコードをチェックできます。</p>\n<h3 id=\"multiple-packages\"><a href=\"#multiple-packages\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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>\n<p>React は<a href=\"http://danluu.com/monorepo/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">単一リポジトリ (monorepo)</a> です。そのリポジトリには複数の別々のパッケージが含まれているので、それらの変更はまとめて調整でき、issue も 1 箇所にまとまっています。</p>\n<h3 id=\"react-core\"><a href=\"#react-core\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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 コア (core) </h3>\n<p>React の「コア (core)」は<a href=\"/docs/react-api.html#react\">最上位の React API</a> を全て含んでいます。例えば：</p>\n<ul>\n<li><code class=\"gatsby-code-text\">React.createElement()</code></li>\n<li><code class=\"gatsby-code-text\">React.Component</code></li>\n<li><code class=\"gatsby-code-text\">React.Children</code></li>\n</ul>\n<p><strong>React core にはコンポーネントの定義に必要な API のみが含まれています。</strong><a href=\"/docs/reconciliation.html\">リコンシリエーション</a>のアルゴリズムやあらゆるプラットフォーム固有のコードは含まれません。コアは React DOM や React Native コンポーネントに使われています。</p>\n<p>React core のコードはソースツリーの <a href=\"https://github.com/facebook/react/tree/main/packages/react\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">packages/react</code></a> に格納されています。npm では <a href=\"https://www.npmjs.com/package/react\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react</code></a> パッケージとして利用可能です。対応するスタンドアロンなブラウザ向けのビルドは <code class=\"gatsby-code-text\">react.js</code> と呼ばれ、<code class=\"gatsby-code-text\">React</code> というグローバル変数をエクスポートします。</p>\n<h3 id=\"renderers\"><a href=\"#renderers\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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>\n<p>React は元々 DOM のために作成されましたが、後になって <a href=\"https://reactnative.dev/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React Native</a> によりネイティブなプラットフォームもサポートするようになりました。これにより React の内部に “レンダラ (renderer)” の概念が導入されました。</p>\n<p><strong>レンダラは React ツリーを、基盤となるプラットフォーム固有の呼び出しへと変換する方法を管理します。</strong></p>\n<p>レンダラは <a href=\"https://github.com/facebook/react/tree/main/packages/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">packages/</code></a> にも格納されています：</p>\n<ul>\n<li><a href=\"https://github.com/facebook/react/tree/main/packages/react-dom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React DOM Renderer</a> は React コンポーネントを DOM に変換します。<a href=\"/docs/react-dom.html\">トップレベルの <code class=\"gatsby-code-text\">ReactDOM</code> API</a> を実装し、npm では <a href=\"https://www.npmjs.com/package/react-dom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-dom</code></a> パッケージとして利用可能です。<code class=\"gatsby-code-text\">react-dom.js</code> と呼ばれるスタンドアロンなブラウザ向けバンドルとしても使用でき、<code class=\"gatsby-code-text\">ReactDOM</code> というグローバル変数をエクスポートします。</li>\n<li><a href=\"https://github.com/facebook/react/tree/main/packages/react-native-renderer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React Native Renderer</a> は React コンポーネントをネイティブのビューに変換します。React Native の内部で使われています。</li>\n<li><a href=\"https://github.com/facebook/react/tree/main/packages/react-test-renderer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React Test Renderer</a> は React コンポーネントを JSON ツリーに変換します。<a href=\"https://facebook.github.io/jest\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Jest</a> の<a href=\"https://facebook.github.io/jest/blog/2016/07/27/jest-14.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">スナップショットテスト機能</a>で使用され、npm では <a href=\"https://www.npmjs.com/package/react-test-renderer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">react-test-renderer</a> パッケージとして利用可能です。</li>\n</ul>\n<p>その他に公式にサポートしているレンダラは <a href=\"https://github.com/facebook/react/tree/main/packages/react-art\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-art</code></a> だけです。個別の <a href=\"https://github.com/reactjs/react-art\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub リポジトリ</a>にありましたが、現在はメインのソースツリーに移動しました。</p>\n<blockquote>\n<p><strong>補足：</strong></p>\n<p>技術的に、<a href=\"https://github.com/facebook/react/tree/main/packages/react-native-renderer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-native-renderer</code></a> は React に React Native の実装とやり取りの方法を教える非常に薄い層です。ネイティブのビューを管理する実際のプラットフォーム固有のコードは、コンポーネントと共に <a href=\"https://github.com/facebook/react-native\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React Native リポジトリ</a> にあります。</p>\n</blockquote>\n<h3 id=\"reconcilers\"><a href=\"#reconcilers\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>リコンサイラ (reconciler) </h3>\n<p>React DOM と React Native のように大幅に異なるレンダラでも多くのロジックを共有する必要があります。特に、ツリーの<a href=\"/docs/reconciliation.html\">リコンシリエーション</a>のアルゴリズムは可能なかぎり同じものにして、宣言型レンダリング、独自コンポーネント、state、ライフサイクルメソッドおよび ref がプラットフォーム間で一貫した動作となるようにするべきです。</p>\n<p>異なるレンダラ間でコードの一部を共有することでこの課題を解決します。React のこの箇所を “リコンサイラ（reconciler, 差分検出処理）” と呼んでいます。<code class=\"gatsby-code-text\">setState()</code> のような更新がスケジュールされると、差分検出処理ではツリー内のコンポーネントで <code class=\"gatsby-code-text\">render()</code> を呼び出して、コンポーネントをマウント、更新、もしくはアンマウントします。</p>\n<p>リコンサイラは、パブリック API がないため、個別にパッケージ化されていません。代わりに、それらは React DOM や React Native などのレンダラーによってのみ使用されます。</p>\n<h3 id=\"stack-reconciler\"><a href=\"#stack-reconciler\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>スタック (stack) リコンサイラ </h3>\n<p>“stack” リコンサイラは React 15 およびそれ以前で実装されています。それ以降は使用されていませんが、<a href=\"/docs/implementation-notes.html\">次のセクション</a>では詳細に説明されています。</p>\n<h3 id=\"fiber-reconciler\"><a href=\"#fiber-reconciler\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Fiber リコンサイラ </h3>\n<p>“fiber” リコンサイラは stack リコンサイラが内在的に抱える問題を解決し、いくつかの長年の問題を修正することを目的とした新しい取り組みです。React 16 以降はデフォルトのリコンサイラとなっています。</p>\n<p>主な目的は以下の通りです：</p>\n<ul>\n<li>中断可能な作業を小分けに分割する機能</li>\n<li>進行中の作業に優先順位を付けたり、再配置や再利用をする機能</li>\n<li>React でレイアウトをサポートするための親子間を行き来しながらレンダーする機能</li>\n<li>render() から複数の要素を返す機能</li>\n<li>error boundary のサポートの向上</li>\n</ul>\n<p>React Fiber のアーキテクチャに関して<a href=\"https://github.com/acdlite/react-fiber-architecture\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ここ</a>や<a href=\"https://blog.ag-grid.com/inside-fiber-an-in-depth-overview-of-the-new-reconciliation-algorithm-in-react\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ここ</a>で読むことができます。React 16 と共にリリースされていますが、非同期機能についてはデフォルトではまだ有効化されていません。</p>\n<p>ソースコードは <a href=\"https://github.com/facebook/react/tree/main/packages/react-reconciler\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">packages/react-reconciler</code></a> に格納されています。</p>\n<h3 id=\"event-system\"><a href=\"#event-system\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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>\n<p>React はブラウザ間でのイベント挙動の差異を吸収するため、ネイティブイベントの上にレイヤーを実装しています。ソースコードは <a href=\"https://github.com/facebook/react/tree/main/packages/react-dom/src/events\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">packages/react-dom/src/events</code></a> にあります。</p>\n<h3 id=\"what-next\"><a href=\"#what-next\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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>\n<p>React 16 以前のリコンサイラについてより詳細に学ぶには<a href=\"/docs/implementation-notes.html\">次のセクション</a>を読んでください。新しいリコンサイラの内部についてはまだドキュメント化していません。</p>","frontmatter":{"title":"コードベースの概要","next":"implementation-notes.html","prev":"how-to-contribute.html"},"fields":{"path":"content/docs/codebase-overview.md","slug":"docs/codebase-overview.html"}}},"pageContext":{"slug":"docs/codebase-overview.html"}},"staticQueryHashes":[]}