{"componentChunkName":"component---src-templates-docs-js","path":"/docs/codebase-overview.html","result":{"data":{"markdownRemark":{"html":"<p>This section will give you an overview of the React codebase organization, its conventions, and the implementation.</p>\n<p>If you want to <a href=\"/docs/how-to-contribute.html\">contribute to React</a> we hope that this guide will help you feel more comfortable making changes.</p>\n<p>We don’t necessarily recommend any of these conventions in React apps. Many of them exist for historical reasons and might change with time.</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>Top-Level Folders </h3>\n<p>After cloning the <a href=\"https://github.com/facebook/react\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React repository</a>, you will see a few top-level folders in it:</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> contains metadata (such as <code class=\"gatsby-code-text\">package.json</code>) and the source code (<code class=\"gatsby-code-text\">src</code> subdirectory) for all packages in the React repository. <strong>If your change is related to the code, the <code class=\"gatsby-code-text\">src</code> subdirectory of each package is where you’ll spend most of your time.</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> contains a few small React test applications for contributors.</li>\n<li><code class=\"gatsby-code-text\">build</code> is the build output of React. It is not in the repository but it will appear in your React clone after you <a href=\"/docs/how-to-contribute.html#development-workflow\">build it</a> for the first time.</li>\n</ul>\n<p>The documentation is hosted <a href=\"https://github.com/reactjs/reactjs.org\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">in a separate repository from React</a>.</p>\n<p>There are a few other top-level folders but they are mostly used for the tooling and you likely won’t ever encounter them when contributing.</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>Colocated Tests </h3>\n<p>We don’t have a top-level directory for unit tests. Instead, we put them into a directory called <code class=\"gatsby-code-text\">__tests__</code> relative to the files that they test.</p>\n<p>For example, a test for <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> is located in <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> right next to it.</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>Warnings and Invariants </h3>\n<p>The React codebase uses <code class=\"gatsby-code-text\">console.error</code> to display warnings:</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>Warnings are only enabled in development. In production, they are completely stripped out. If you need to forbid some code path from executing, use <code class=\"gatsby-code-text\">invariant</code> module instead:</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>The invariant is thrown when the <code class=\"gatsby-code-text\">invariant</code> condition is <code class=\"gatsby-code-text\">false</code>.</strong></p>\n<p>“Invariant” is just a way of saying “this condition always holds true”. You can think about it as making an assertion.</p>\n<p>It is important to keep development and production behavior similar, so <code class=\"gatsby-code-text\">invariant</code> throws both in development and in production. The error messages are automatically replaced with error codes in production to avoid negatively affecting the byte size.</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>Development and Production </h3>\n<p>You can use <code class=\"gatsby-code-text\">__DEV__</code> pseudo-global variable in the codebase to guard development-only blocks of code.</p>\n<p>It is inlined during the compile step, and turns into <code class=\"gatsby-code-text\">process.env.NODE_ENV !== 'production'</code> checks in the CommonJS builds.</p>\n<p>For standalone builds, it becomes <code class=\"gatsby-code-text\">true</code> in the unminified build, and gets completely stripped out with the <code class=\"gatsby-code-text\">if</code> blocks it guards in the minified build.</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>We recently started introducing <a href=\"https://flow.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Flow</a> checks to the codebase. Files marked with the <code class=\"gatsby-code-text\">@flow</code> annotation in the license header comment are being typechecked.</p>\n<p>We accept pull requests <a href=\"https://github.com/facebook/react/pull/7600/files\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">adding Flow annotations to existing code</a>. Flow annotations look like this:</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>When possible, new code should use Flow annotations.\nYou can run <code class=\"gatsby-code-text\">yarn flow</code> locally to check your code with 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>Multiple Packages </h3>\n<p>React is a <a href=\"https://danluu.com/monorepo/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">monorepo</a>. Its repository contains multiple separate packages so that their changes can be coordinated together, and issues live in one place.</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>The “core” of React includes all the <a href=\"/docs/react-api.html#react\">top-level <code class=\"gatsby-code-text\">React</code> APIs</a>, for example:</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 only includes the APIs necessary to define components.</strong> It does not include the <a href=\"/docs/reconciliation.html\">reconciliation</a> algorithm or any platform-specific code. It is used both by React DOM and React Native components.</p>\n<p>The code for React core is located in <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> in the source tree. It is available on npm as the <a href=\"https://www.npmjs.com/package/react\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react</code></a> package. The corresponding standalone browser build is called <code class=\"gatsby-code-text\">react.js</code>, and it exports a global called <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>Renderers </h3>\n<p>React was originally created for the DOM but it was later adapted to also support native platforms with <a href=\"https://reactnative.dev/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React Native</a>. This introduced the concept of “renderers” to React internals.</p>\n<p><strong>Renderers manage how a React tree turns into the underlying platform calls.</strong></p>\n<p>Renderers are also located in <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> renders React components to the DOM. It implements <a href=\"/docs/react-dom.html\">top-level <code class=\"gatsby-code-text\">ReactDOM</code> APIs</a> and is available as <a href=\"https://www.npmjs.com/package/react-dom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-dom</code></a> npm package. It can also be used as standalone browser bundle called <code class=\"gatsby-code-text\">react-dom.js</code> that exports a <code class=\"gatsby-code-text\">ReactDOM</code> global.</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> renders React components to native views. It is used internally by 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> renders React components to JSON trees. It is used by the <a href=\"https://facebook.github.io/jest/blog/2016/07/27/jest-14.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Snapshot Testing</a> feature of <a href=\"https://facebook.github.io/jest\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Jest</a> and is available as <a href=\"https://www.npmjs.com/package/react-test-renderer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">react-test-renderer</a> npm package.</li>\n</ul>\n<p>The only other officially supported renderer is <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>. It used to be in a separate <a href=\"https://github.com/reactjs/react-art\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub repository</a> but we moved it into the main source tree for now.</p>\n<blockquote>\n<p><strong>Note:</strong></p>\n<p>Technically the <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> is a very thin layer that teaches React to interact with React Native implementation. The real platform-specific code managing the native views lives in the <a href=\"https://github.com/facebook/react-native\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">React Native repository</a> together with its components.</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>Reconcilers </h3>\n<p>Even vastly different renderers like React DOM and React Native need to share a lot of logic. In particular, the <a href=\"/docs/reconciliation.html\">reconciliation</a> algorithm should be as similar as possible so that declarative rendering, custom components, state, lifecycle methods, and refs work consistently across platforms.</p>\n<p>To solve this, different renderers share some code between them. We call this part of React a “reconciler”. When an update such as <code class=\"gatsby-code-text\">setState()</code> is scheduled, the reconciler calls <code class=\"gatsby-code-text\">render()</code> on components in the tree and mounts, updates, or unmounts them.</p>\n<p>Reconcilers are not packaged separately because they currently have no public API. Instead, they are exclusively used by renderers such as React DOM and 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 Reconciler </h3>\n<p>The “stack” reconciler is the implementation powering React 15 and earlier. We have since stopped using it, but it is documented in detail in the <a href=\"/docs/implementation-notes.html\">next section</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 Reconciler </h3>\n<p>The “fiber” reconciler is a new effort aiming to resolve the problems inherent in the stack reconciler and fix a few long-standing issues. It has been the default reconciler since React 16.</p>\n<p>Its main goals are:</p>\n<ul>\n<li>Ability to split interruptible work in chunks.</li>\n<li>Ability to prioritize, rebase and reuse work in progress.</li>\n<li>Ability to yield back and forth between parents and children to support layout in React.</li>\n<li>Ability to return multiple elements from <code class=\"gatsby-code-text\">render()</code>.</li>\n<li>Better support for error boundaries.</li>\n</ul>\n<p>You can read more about React Fiber Architecture <a href=\"https://github.com/acdlite/react-fiber-architecture\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">here</a> and <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\">here</a>. While it has shipped with React 16, the async features are not enabled by default yet.</p>\n<p>Its source code is located in <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>Event System </h3>\n<p>React implements a layer over native events to smooth out cross-browser differences. Its source code is located in <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>What Next? </h3>\n<p>Read the <a href=\"/docs/implementation-notes.html\">next section</a> to learn about the pre-React 16 implementation of reconciler in more detail. We haven’t documented the internals of the new reconciler yet.</p>","frontmatter":{"title":"Codebase Overview","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":[]}