{"componentChunkName":"component---src-templates-docs-js","path":"/docs/react-dom.html","result":{"data":{"markdownRemark":{"html":"<div class=\"scary\">\n<blockquote>\n<p>These docs are old and won’t be updated. Go to <a href=\"https://react.dev/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">react.dev</a> for the new React docs.</p>\n<p>These new documentation pages teach modern React:</p>\n<ul>\n<li><a href=\"https://react.dev/reference/react-dom/components\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-dom</code>: Components</a></li>\n<li><a href=\"https://react.dev/reference/react-dom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-dom</code>: APIs</a></li>\n<li><a href=\"https://react.dev/reference/react-dom/client\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-dom</code>: Client APIs</a></li>\n<li><a href=\"https://react.dev/reference/react-dom/server\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">react-dom</code>: Server APIs</a></li>\n</ul>\n</blockquote>\n</div>\n<p>The <code class=\"gatsby-code-text\">react-dom</code> package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch to get outside the React model if you need to.</p>\n<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 operator\">*</span> <span class=\"token keyword\">as</span> ReactDOM <span class=\"token keyword\">from</span> <span class=\"token string\">'react-dom'</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>If you use ES5 with npm, you can write:</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> ReactDOM <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'react-dom'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>The <code class=\"gatsby-code-text\">react-dom</code> package also provides modules specific to client and server apps:</p>\n<ul>\n<li><a href=\"/docs/react-dom-client.html\"><code class=\"gatsby-code-text\">react-dom/client</code></a></li>\n<li><a href=\"/docs/react-dom-server.html\"><code class=\"gatsby-code-text\">react-dom/server</code></a></li>\n</ul>\n<h2 id=\"overview\"><a href=\"#overview\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Overview </h2>\n<p>The <code class=\"gatsby-code-text\">react-dom</code> package exports these methods:</p>\n<ul>\n<li><a href=\"#createportal\"><code class=\"gatsby-code-text\">createPortal()</code></a></li>\n<li><a href=\"#flushsync\"><code class=\"gatsby-code-text\">flushSync()</code></a></li>\n</ul>\n<p>These <code class=\"gatsby-code-text\">react-dom</code> methods are also exported, but are considered legacy:</p>\n<ul>\n<li><a href=\"#render\"><code class=\"gatsby-code-text\">render()</code></a></li>\n<li><a href=\"#hydrate\"><code class=\"gatsby-code-text\">hydrate()</code></a></li>\n<li><a href=\"#finddomnode\"><code class=\"gatsby-code-text\">findDOMNode()</code></a></li>\n<li><a href=\"#unmountcomponentatnode\"><code class=\"gatsby-code-text\">unmountComponentAtNode()</code></a></li>\n</ul>\n<blockquote>\n<p>Note: </p>\n<p>Both <code class=\"gatsby-code-text\">render</code> and <code class=\"gatsby-code-text\">hydrate</code> have been replaced with new <a href=\"/docs/react-dom-client.html\">client methods</a> in React 18. These methods will warn that 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\">here</a>).</p>\n</blockquote>\n<h3 id=\"browser-support\"><a href=\"#browser-support\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Browser Support </h3>\n<p>React supports all modern browsers, although <a href=\"/docs/javascript-environment-requirements.html\">some polyfills are required</a> for older versions.</p>\n<blockquote>\n<p>Note</p>\n<p>We do not support older browsers that don’t support ES5 methods or microtasks such as Internet Explorer. You may find that your apps do work in older browsers if polyfills such as <a href=\"https://github.com/es-shims/es5-shim\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">es5-shim and es5-sham</a> are included in the page, but you’re on your own if you choose to take this path.</p>\n</blockquote>\n<h2 id=\"reference\"><a href=\"#reference\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Reference </h2>\n<h3 id=\"createportal\"><a href=\"#createportal\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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\">createPortal()</code> </h3>\n<div class=\"scary\">\n<blockquote>\n<p>This content is out of date.</p>\n<p>Read the new React documentation for <a href=\"https://react.dev/reference/react-dom/createPortal\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">createPortal</code></a>.</p>\n</blockquote>\n</div>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token function\">createPortal</span><span class=\"token punctuation\">(</span>child<span class=\"token punctuation\">,</span> container<span class=\"token punctuation\">)</span></code></pre></div>\n<p>Creates a portal. Portals provide a way to <a href=\"/docs/portals.html\">render children into a DOM node that exists outside the hierarchy of the DOM component</a>.</p>\n<h3 id=\"flushsync\"><a href=\"#flushsync\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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\">flushSync()</code> </h3>\n<div class=\"scary\">\n<blockquote>\n<p>This content is out of date.</p>\n<p>Read the new React documentation for <a href=\"https://react.dev/reference/react-dom/flushSync\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">flushSync</code></a>.</p>\n</blockquote>\n</div>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token function\">flushSync</span><span class=\"token punctuation\">(</span>callback<span class=\"token punctuation\">)</span></code></pre></div>\n<p>Force React to flush any updates inside the provided callback synchronously. This ensures that the DOM is updated immediately.</p>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token comment\">// Force this state update to be synchronous.</span>\n<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>\n  <span class=\"token function\">setCount</span><span class=\"token punctuation\">(</span>count <span class=\"token operator\">+</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token comment\">// By this point, DOM is updated.</span></code></pre></div>\n<blockquote>\n<p>Note:</p>\n<p><code class=\"gatsby-code-text\">flushSync</code> can significantly hurt performance. Use sparingly.</p>\n<p><code class=\"gatsby-code-text\">flushSync</code> may force pending Suspense boundaries to show their <code class=\"gatsby-code-text\">fallback</code> state.</p>\n<p><code class=\"gatsby-code-text\">flushSync</code> may also run pending effects and synchronously apply any updates they contain before returning.</p>\n<p><code class=\"gatsby-code-text\">flushSync</code> may also flush updates outside the callback when necessary to flush the updates inside the callback. For example, if there are pending updates from a click, React may flush those before flushing the updates inside the callback.</p>\n</blockquote>\n<h2 id=\"legacy-reference\"><a href=\"#legacy-reference\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Legacy Reference </h2>\n<h3 id=\"render\"><a href=\"#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><code class=\"gatsby-code-text\">render()</code> </h3>\n<div class=\"scary\">\n<blockquote>\n<p>This content is out of date.</p>\n<p>Read the new React documentation for <a href=\"https://react.dev/reference/react-dom/render\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">render</code></a>.</p>\n</blockquote>\n</div>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token function\">render</span><span class=\"token punctuation\">(</span>element<span class=\"token punctuation\">,</span> container<span class=\"token punctuation\">[</span><span class=\"token punctuation\">,</span> callback<span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span></code></pre></div>\n<blockquote>\n<p>Note:</p>\n<p><code class=\"gatsby-code-text\">render</code> has been replaced with <code class=\"gatsby-code-text\">createRoot</code> in React 18. See <a href=\"/docs/react-dom-client.html#createroot\">createRoot</a> for more info.</p>\n</blockquote>\n<p>Render a React element into the DOM in the supplied <code class=\"gatsby-code-text\">container</code> and return a <a href=\"/docs/more-about-refs.html\">reference</a> to the component (or returns <code class=\"gatsby-code-text\">null</code> for <a href=\"/docs/components-and-props.html#function-and-class-components\">stateless components</a>).</p>\n<p>If the React element was previously rendered into <code class=\"gatsby-code-text\">container</code>, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element.</p>\n<p>If the optional callback is provided, it will be executed after the component is rendered or updated.</p>\n<blockquote>\n<p>Note:</p>\n<p><code class=\"gatsby-code-text\">render()</code> controls the contents of the container node you pass in. Any existing DOM elements inside are replaced when first called. Later calls use React’s DOM diffing algorithm for efficient updates.</p>\n<p><code class=\"gatsby-code-text\">render()</code> does not modify the container node (only modifies the children of the container). It may be possible to insert a component to an existing DOM node without overwriting the existing children.</p>\n<p><code class=\"gatsby-code-text\">render()</code> currently returns a reference to the root <code class=\"gatsby-code-text\">ReactComponent</code> instance. However, using this return value is legacy\nand should be avoided because future versions of React may render components asynchronously in some cases. If you need a reference to the root <code class=\"gatsby-code-text\">ReactComponent</code> instance, the preferred solution is to attach a\n<a href=\"/docs/refs-and-the-dom.html#callback-refs\">callback ref</a> to the root element.</p>\n<p>Using <code class=\"gatsby-code-text\">render()</code> to hydrate a server-rendered container is deprecated. Use <a href=\"/docs/react-dom-client.html#hydrateroot\"><code class=\"gatsby-code-text\">hydrateRoot()</code></a> instead.</p>\n</blockquote>\n<hr>\n<h3 id=\"hydrate\"><a href=\"#hydrate\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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\">hydrate()</code> </h3>\n<div class=\"scary\">\n<blockquote>\n<p>This content is out of date.</p>\n<p>Read the new React documentation for <a href=\"https://react.dev/reference/react-dom/hydrate\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">hydrate</code></a>.</p>\n</blockquote>\n</div>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token function\">hydrate</span><span class=\"token punctuation\">(</span>element<span class=\"token punctuation\">,</span> container<span class=\"token punctuation\">[</span><span class=\"token punctuation\">,</span> callback<span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span></code></pre></div>\n<blockquote>\n<p>Note:</p>\n<p><code class=\"gatsby-code-text\">hydrate</code> has been replaced with <code class=\"gatsby-code-text\">hydrateRoot</code> in React 18. See <a href=\"/docs/react-dom-client.html#hydrateroot\">hydrateRoot</a> for more info.</p>\n</blockquote>\n<p>Same as <a href=\"#render\"><code class=\"gatsby-code-text\">render()</code></a>, but is used to hydrate a container whose HTML contents were rendered by <a href=\"/docs/react-dom-server.html\"><code class=\"gatsby-code-text\">ReactDOMServer</code></a>. React will attempt to attach event listeners to the existing markup.</p>\n<p>React expects that the rendered content is identical between the server and the client. It can patch up differences in text content, but you should treat mismatches as bugs and fix them. In development mode, React warns about mismatches during hydration. There are no guarantees that attribute differences will be patched up in case of mismatches. This is important for performance reasons because in most apps, mismatches are rare, and so validating all markup would be prohibitively expensive.</p>\n<p>If a single element’s attribute or text content is unavoidably different between the server and the client (for example, a timestamp), you may silence the warning by adding <code class=\"gatsby-code-text\">suppressHydrationWarning={true}</code> to the element. It only works one level deep, and is intended to be an escape hatch. Don’t overuse it. Unless it’s text content, React still won’t attempt to patch it up, so it may remain inconsistent until future updates.</p>\n<p>If you intentionally need to render something different on the server and the client, you can do a two-pass rendering. Components that render something different on the client can read a state variable like <code class=\"gatsby-code-text\">this.state.isClient</code>, which you can set to <code class=\"gatsby-code-text\">true</code> in <code class=\"gatsby-code-text\">componentDidMount()</code>. This way the initial render pass will render the same content as the server, avoiding mismatches, but an additional pass will happen synchronously right after hydration. Note that this approach will make your components slower because they have to render twice, so use it with caution.</p>\n<p>Remember to be mindful of user experience on slow connections. The JavaScript code may load significantly later than the initial HTML render, so if you render something different in the client-only pass, the transition can be jarring. However, if executed well, it may be beneficial to render a “shell” of the application on the server, and only show some of the extra widgets on the client. To learn how to do this without getting the markup mismatch issues, refer to the explanation in the previous paragraph.</p>\n<hr>\n<h3 id=\"unmountcomponentatnode\"><a href=\"#unmountcomponentatnode\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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\">unmountComponentAtNode()</code> </h3>\n<div class=\"scary\">\n<blockquote>\n<p>This content is out of date.</p>\n<p>Read the new React documentation for <a href=\"https://react.dev/reference/react-dom/unmountComponentAtNode\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">unmountComponentAtNode</code></a>.</p>\n</blockquote>\n</div>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token function\">unmountComponentAtNode</span><span class=\"token punctuation\">(</span>container<span class=\"token punctuation\">)</span></code></pre></div>\n<blockquote>\n<p>Note:</p>\n<p><code class=\"gatsby-code-text\">unmountComponentAtNode</code> has been replaced with <code class=\"gatsby-code-text\">root.unmount()</code> in React 18. See <a href=\"/docs/react-dom-client.html#createroot\">createRoot</a> for more info.</p>\n</blockquote>\n<p>Remove a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing. Returns <code class=\"gatsby-code-text\">true</code> if a component was unmounted and <code class=\"gatsby-code-text\">false</code> if there was no component to unmount.</p>\n<hr>\n<h3 id=\"finddomnode\"><a href=\"#finddomnode\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 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\">findDOMNode()</code> </h3>\n<div class=\"scary\">\n<blockquote>\n<p>This content is out of date.</p>\n<p>Read the new React documentation for <a href=\"https://react.dev/reference/react-dom/findDOMNode\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"gatsby-code-text\">findDOMNode</code></a>.</p>\n</blockquote>\n</div>\n<blockquote>\n<p>Note:</p>\n<p><code class=\"gatsby-code-text\">findDOMNode</code> is an escape hatch used to access the underlying DOM node. In most cases, use of this escape hatch is discouraged because it pierces the component abstraction. <a href=\"/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage\">It has been deprecated in <code class=\"gatsby-code-text\">StrictMode</code>.</a></p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\"><span class=\"token function\">findDOMNode</span><span class=\"token punctuation\">(</span>component<span class=\"token punctuation\">)</span></code></pre></div>\n<p>If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements. <strong>In most cases, you can attach a ref to the DOM node and avoid using <code class=\"gatsby-code-text\">findDOMNode</code> at all.</strong></p>\n<p>When a component renders to <code class=\"gatsby-code-text\">null</code> or <code class=\"gatsby-code-text\">false</code>, <code class=\"gatsby-code-text\">findDOMNode</code> returns <code class=\"gatsby-code-text\">null</code>. When a component renders to a string, <code class=\"gatsby-code-text\">findDOMNode</code> returns a text DOM node containing that value. As of React 16, a component may return a fragment with multiple children, in which case <code class=\"gatsby-code-text\">findDOMNode</code> will return the DOM node corresponding to the first non-empty child.</p>\n<blockquote>\n<p>Note:</p>\n<p><code class=\"gatsby-code-text\">findDOMNode</code> only works on mounted components (that is, components that have been placed in the DOM). If you try to call this on a component that has not been mounted yet (like calling <code class=\"gatsby-code-text\">findDOMNode()</code> in <code class=\"gatsby-code-text\">render()</code> on a component that has yet to be created) an exception will be thrown.</p>\n<p><code class=\"gatsby-code-text\">findDOMNode</code> cannot be used on function components.</p>\n</blockquote>\n<hr>","frontmatter":{"title":"ReactDOM","next":null,"prev":null},"fields":{"path":"content/docs/reference-react-dom.md","slug":"docs/react-dom.html"}}},"pageContext":{"slug":"docs/react-dom.html"}},"staticQueryHashes":[]}