CINXE.COM
<!DOCTYPE html><html lang="en" dir="ltr"><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width, initial-scale=1" data-next-head=""/><script async="" src="https://www.googletagmanager.com/gtag/js?id=G-B1E83PJ3RT"></script><title data-next-head="">React Compiler – React</title><link rel="canonical" href="https://react.dev/learn/react-compiler" data-next-head=""/><link rel="alternate" href="https://react.dev/learn/react-compiler" hrefLang="x-default" data-next-head=""/><link rel="alternate" hrefLang="en" href="https://react.dev/learn/react-compiler" data-next-head=""/><link rel="alternate" hrefLang="zh-hans" href="https://zh-hans.react.dev/learn/react-compiler" data-next-head=""/><link rel="alternate" hrefLang="es" href="https://es.react.dev/learn/react-compiler" data-next-head=""/><link rel="alternate" hrefLang="fr" href="https://fr.react.dev/learn/react-compiler" data-next-head=""/><link rel="alternate" hrefLang="ja" href="https://ja.react.dev/learn/react-compiler" data-next-head=""/><link rel="alternate" hrefLang="tr" href="https://tr.react.dev/learn/react-compiler" data-next-head=""/><link rel="alternate" hrefLang="ko" href="https://ko.react.dev/learn/react-compiler" data-next-head=""/><meta property="fb:app_id" content="623268441017527" data-next-head=""/><meta property="og:type" content="website" data-next-head=""/><meta property="og:url" content="https://react.dev/learn/react-compiler" data-next-head=""/><meta property="og:title" content="React Compiler – React" data-next-head=""/><meta property="og:description" content="The library for web and native user interfaces" data-next-head=""/><meta property="og:image" content="https://react.dev/images/og-learn.png" data-next-head=""/><meta name="twitter:card" content="summary_large_image" data-next-head=""/><meta name="twitter:site" content="@reactjs" data-next-head=""/><meta name="twitter:creator" content="@reactjs" data-next-head=""/><meta name="twitter:title" content="React Compiler – React" data-next-head=""/><meta name="twitter:description" content="The library for web and native user interfaces" data-next-head=""/><meta name="twitter:image" content="https://react.dev/images/og-learn.png" data-next-head=""/><meta name="google-site-verification" content="sIlAGs48RulR4DdP95YSWNKZIEtCqQmRjzn-Zq-CcD0" data-next-head=""/><meta name="algolia-search-order" content="14" data-next-head=""/><link rel="preload" href="/fonts/Source-Code-Pro-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preload" href="https://react.dev/fonts/Optimistic_Display_W_Md.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preload" href="https://react.dev/fonts/Optimistic_Display_W_SBd.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preload" href="https://react.dev/fonts/Optimistic_Display_W_Bd.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preload" href="https://react.dev/fonts/Optimistic_Text_W_Md.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preload" href="https://react.dev/fonts/Optimistic_Text_W_Bd.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preload" href="https://react.dev/fonts/Optimistic_Text_W_Rg.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preload" href="https://react.dev/fonts/Optimistic_Text_W_It.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-head=""/><link rel="preconnect" href="https://1FCF9AYYAT-dsn.algolia.net" data-next-head=""/><link rel="preload" href="/_next/static/css/30a0450f062b33f4.css" as="style"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/site.webmanifest"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#404756"/><meta name="msapplication-TileColor" content="#2b5797"/><meta name="theme-color" content="#23272f"/><link rel="preload" as="image" imageSrcSet="/_next/image?url=%2Fimages%2Fuwu.png&w=64&q=75 1x, /_next/image?url=%2Fimages%2Fuwu.png&w=128&q=75 2x" data-next-head=""/><link rel="stylesheet" href="/_next/static/css/30a0450f062b33f4.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-35e65ce5d83d5425.js" defer=""></script><script src="/_next/static/chunks/framework-76ad44d61c11f057.js" defer=""></script><script src="/_next/static/chunks/main-6b2aa10951d4c273.js" defer=""></script><script src="/_next/static/chunks/pages/_app-6d7b64b3b21a9551.js" defer=""></script><script src="/_next/static/chunks/668-e65a23e6848f265b.js" defer=""></script><script src="/_next/static/chunks/679-d6cf26e485b33427.js" defer=""></script><script src="/_next/static/chunks/pages/%5B%5B...markdownPath%5D%5D-df3d4d0e644b3e5c.js" defer=""></script><script src="/_next/static/_Fz6u7K2TvuR-_M7SFBnH/_buildManifest.js" defer=""></script><script src="/_next/static/_Fz6u7K2TvuR-_M7SFBnH/_ssgManifest.js" defer=""></script></head><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-B1E83PJ3RT');</script><body class="font-text font-medium antialiased text-lg bg-wash dark:bg-wash-dark text-secondary dark:text-secondary-dark leading-base"><script> (function () { try { let logShown = false; function setUwu(isUwu) { try { if (isUwu) { localStorage.setItem('uwu', true); document.documentElement.classList.add('uwu'); if (!logShown) { console.log('uwu mode! turn off with ?uwu=0'); console.log('logo credit to @sawaratsuki1004 via https://github.com/SAWARATSUKI/ServiceLogos'); logShown = true; } } else { localStorage.removeItem('uwu'); document.documentElement.classList.remove('uwu'); console.log('uwu mode off. turn on with ?uwu'); } } catch (err) { } } window.__setUwu = setUwu; function checkQueryParam() { const params = new URLSearchParams(window.location.search); const value = params.get('uwu'); switch(value) { case '': case 'true': case '1': return true; case 'false': case '0': return false; default: return null; } } function checkLocalStorage() { try { return localStorage.getItem('uwu') === 'true'; } catch (err) { return false; } } const uwuQueryParam = checkQueryParam(); if (uwuQueryParam != null) { setUwu(uwuQueryParam); } else if (checkLocalStorage()) { document.documentElement.classList.add('uwu'); } } catch (err) { } })(); </script><script> (function () { function setTheme(newTheme) { window.__theme = newTheme; if (newTheme === 'dark') { document.documentElement.classList.add('dark'); } else if (newTheme === 'light') { document.documentElement.classList.remove('dark'); } } var preferredTheme; try { preferredTheme = localStorage.getItem('theme'); } catch (err) { } window.__setPreferredTheme = function(newTheme) { preferredTheme = newTheme; setTheme(newTheme); try { localStorage.setItem('theme', newTheme); } catch (err) { } }; var initialTheme = preferredTheme; var darkQuery = window.matchMedia('(prefers-color-scheme: dark)'); if (!initialTheme) { initialTheme = darkQuery.matches ? 'dark' : 'light'; } setTheme(initialTheme); darkQuery.addEventListener('change', function (e) { if (!preferredTheme) { setTheme(e.matches ? 'dark' : 'light'); } }); // Detect whether the browser is Mac to display platform specific content // An example of such content can be the keyboard shortcut displayed in the search bar document.documentElement.classList.add( window.navigator.platform.includes('Mac') ? "platform-mac" : "platform-win" ); })(); </script><link rel="preload" as="image" imageSrcSet="/_next/image?url=%2Fimages%2Fuwu.png&w=64&q=75 1x, /_next/image?url=%2Fimages%2Fuwu.png&w=128&q=75 2x"/><div id="__next"><div></div><div class="z-40 sticky top-0"><nav class="duration-300 backdrop-filter backdrop-blur-lg backdrop-saturate-200 transition-shadow bg-opacity-90 items-center w-full flex justify-between bg-wash dark:bg-wash-dark dark:bg-opacity-95 px-1.5 lg:pe-5 lg:ps-4 z-40"><div class="flex items-center justify-between w-full h-16 gap-0 sm:gap-3"><div class="flex flex-row 3xl:flex-1 items-centers"><button type="button" aria-label="Menu" class="active:scale-95 transition-transform flex lg:hidden w-12 h-12 rounded-full items-center justify-center hover:bg-primary/5 hover:dark:bg-primary-dark/5 outline-link"><svg width="1.33em" height="1.33em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></button><span data-state="closed" class="flex items-center" style="-webkit-touch-callout:none"><div class="flex items-center"><div class="uwu-visible flex items-center justify-center h-full"><a href="/"><img alt="logo by @sawaratsuki1004" title="logo by @sawaratsuki1004" width="63" height="32" decoding="async" data-nimg="1" class="h-8" style="color:transparent" srcSet="/_next/image?url=%2Fimages%2Fuwu.png&w=64&q=75 1x, /_next/image?url=%2Fimages%2Fuwu.png&w=128&q=75 2x" src="/_next/image?url=%2Fimages%2Fuwu.png&w=128&q=75"/></a></div><div class="uwu-hidden"><a class="active:scale-95 overflow-hidden transition-transform relative items-center text-primary dark:text-primary-dark p-1 whitespace-nowrap outline-link rounded-full 3xl:rounded-xl inline-flex text-lg font-normal gap-2" href="/"><svg width="100%" height="100%" viewBox="-10.5 -9.45 21 18.9" fill="none" xmlns="http://www.w3.org/2000/svg" class="text-sm me-0 w-10 h-10 text-brand dark:text-brand-dark flex origin-center transition-all ease-in-out"><circle cx="0" cy="0" r="2" fill="currentColor"></circle><g stroke="currentColor" stroke-width="1" fill="none"><ellipse rx="10" ry="4.5"></ellipse><ellipse rx="10" ry="4.5" transform="rotate(60)"></ellipse><ellipse rx="10" ry="4.5" transform="rotate(120)"></ellipse></g></svg><span class="sr-only 3xl:not-sr-only">React</span></a></div></div></span><div class="flex flex-column justify-center items-center"><a class=" flex py-2 flex-column justify-center items-center text-gray-50 dark:text-gray-30 hover:text-link hover:dark:text-link-dark hover:underline text-sm ms-1 cursor-pointer" href="/versions">v<!-- -->19</a></div></div><div class="items-center justify-center flex-1 hidden w-full md:flex 3xl:w-auto 3xl:shrink-0 3xl:justify-center"><button type="button" class="flex 3xl:w-[56rem] 3xl:mx-0 relative ps-4 pe-1 py-1 h-10 bg-gray-30/20 dark:bg-gray-40/20 outline-none focus:outline-link betterhover:hover:bg-opacity-80 pointer items-center text-start w-full text-gray-30 rounded-full align-middle text-base"><svg width="1em" height="1em" viewBox="0 0 20 20" class="align-middle me-3 text-gray-30 shrink-0 group-betterhover:hover:text-gray-70"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" stroke-width="2" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg>Search<span class="hidden ms-auto sm:flex item-center me-1"><kbd class="w-5 h-5 border border-transparent me-1 bg-wash dark:bg-wash-dark text-gray-30 align-middle p-0 inline-flex justify-center items-center text-xs text-center rounded-md" data-platform="mac">⌘</kbd><kbd class="w-10 h-5 border border-transparent me-1 bg-wash dark:bg-wash-dark text-gray-30 align-middle p-0 inline-flex justify-center items-center text-xs text-center rounded-md" data-platform="win">Ctrl</kbd><kbd class="w-5 h-5 border border-transparent me-1 bg-wash dark:bg-wash-dark text-gray-30 align-middle p-0 inline-flex justify-center items-center text-xs text-center rounded-md">K</kbd></span></button></div><div class="text-base justify-center items-center gap-1.5 flex 3xl:flex-1 flex-row 3xl:justify-end"><div class="mx-2.5 gap-1.5 hidden lg:flex"><div class="flex flex-auto sm:flex-1"><a class="active:scale-95 transition-transform w-full text-center outline-link py-1.5 px-1.5 xs:px-3 sm:px-4 rounded-full capitalize whitespace-nowrap bg-highlight dark:bg-highlight-dark text-link dark:text-link-dark" href="/learn">Learn</a></div><div class="flex flex-auto sm:flex-1"><a class="active:scale-95 transition-transform w-full text-center outline-link py-1.5 px-1.5 xs:px-3 sm:px-4 rounded-full capitalize whitespace-nowrap hover:bg-primary/5 hover:dark:bg-primary-dark/5" href="/reference/react">Reference</a></div><div class="flex flex-auto sm:flex-1"><a class="active:scale-95 transition-transform w-full text-center outline-link py-1.5 px-1.5 xs:px-3 sm:px-4 rounded-full capitalize whitespace-nowrap hover:bg-primary/5 hover:dark:bg-primary-dark/5" href="/community">Community</a></div><div class="flex flex-auto sm:flex-1"><a class="active:scale-95 transition-transform w-full text-center outline-link py-1.5 px-1.5 xs:px-3 sm:px-4 rounded-full capitalize whitespace-nowrap hover:bg-primary/5 hover:dark:bg-primary-dark/5" href="/blog">Blog</a></div></div><div class="flex w-full md:hidden"></div><div class="flex items-center -space-x-2.5 xs:space-x-0 "><div class="flex md:hidden"><button aria-label="Search" type="button" class="flex items-center justify-center w-12 h-12 transition-transform rounded-full active:scale-95 md:hidden hover:bg-secondary-button hover:dark:bg-secondary-button-dark outline-link"><svg width="1em" height="1em" viewBox="0 0 20 20" class="w-5 h-5 align-middle"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" stroke-width="2" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div><div class="flex dark:hidden"><button type="button" aria-label="Use Dark Mode" class="flex items-center justify-center w-12 h-12 transition-transform rounded-full active:scale-95 hover:bg-primary/5 hover:dark:bg-primary-dark/5 outline-link"><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 32 32"><g fill="none" fill-rule="evenodd" transform="translate(-440 -200)"><path fill="currentColor" fill-rule="nonzero" stroke="currentColor" stroke-width="0.5" d="M102,21 C102,18.1017141 103.307179,15.4198295 105.51735,13.6246624 C106.001939,13.2310647 105.821611,12.4522936 105.21334,12.3117518 C104.322006,12.1058078 103.414758,12 102.5,12 C95.8722864,12 90.5,17.3722864 90.5,24 C90.5,30.6277136 95.8722864,36 102.5,36 C106.090868,36 109.423902,34.4109093 111.690274,31.7128995 C112.091837,31.2348572 111.767653,30.5041211 111.143759,30.4810139 C106.047479,30.2922628 102,26.1097349 102,21 Z M102.5,34.5 C96.7007136,34.5 92,29.7992864 92,24 C92,18.2007136 96.7007136,13.5 102.5,13.5 C102.807386,13.5 103.113925,13.5136793 103.419249,13.5407785 C101.566047,15.5446378 100.5,18.185162 100.5,21 C100.5,26.3198526 104.287549,30.7714322 109.339814,31.7756638 L109.516565,31.8092927 C107.615276,33.5209452 105.138081,34.5 102.5,34.5 Z" transform="translate(354.5 192)"></path><polygon points="444 228 468 228 468 204 444 204"></polygon></g></svg></button></div><div class="hidden dark:flex"><button type="button" aria-label="Use Light Mode" class="flex items-center justify-center w-12 h-12 transition-transform rounded-full active:scale-95 hover:bg-primary/5 hover:dark:bg-primary-dark/5 outline-link"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><g fill="none" fill-rule="evenodd" transform="translate(-442 -200)"><g fill="currentColor" transform="translate(356 144)"><path fill-rule="nonzero" d="M108.5 24C108.5 27.5902136 105.590214 30.5 102 30.5 98.4097864 30.5 95.5 27.5902136 95.5 24 95.5 20.4097864 98.4097864 17.5 102 17.5 105.590214 17.5 108.5 20.4097864 108.5 24zM107 24C107 21.2382136 104.761786 19 102 19 99.2382136 19 97 21.2382136 97 24 97 26.7617864 99.2382136 29 102 29 104.761786 29 107 26.7617864 107 24zM101 12.75L101 14.75C101 15.1642136 101.335786 15.5 101.75 15.5 102.164214 15.5 102.5 15.1642136 102.5 14.75L102.5 12.75C102.5 12.3357864 102.164214 12 101.75 12 101.335786 12 101 12.3357864 101 12.75zM95.7255165 14.6323616L96.7485165 16.4038616C96.9556573 16.7625614 97.4143618 16.8854243 97.7730616 16.6782835 98.1317614 16.4711427 98.2546243 16.0124382 98.0474835 15.6537384L97.0244835 13.8822384C96.8173427 13.5235386 96.3586382 13.4006757 95.9999384 13.6078165 95.6412386 13.8149573 95.5183757 14.2736618 95.7255165 14.6323616zM91.8822384 19.0244835L93.6537384 20.0474835C94.0124382 20.2546243 94.4711427 20.1317614 94.6782835 19.7730616 94.8854243 19.4143618 94.7625614 18.9556573 94.4038616 18.7485165L92.6323616 17.7255165C92.2736618 17.5183757 91.8149573 17.6412386 91.6078165 17.9999384 91.4006757 18.3586382 91.5235386 18.8173427 91.8822384 19.0244835zM90.75 25L92.75 25C93.1642136 25 93.5 24.6642136 93.5 24.25 93.5 23.8357864 93.1642136 23.5 92.75 23.5L90.75 23.5C90.3357864 23.5 90 23.8357864 90 24.25 90 24.6642136 90.3357864 25 90.75 25zM92.6323616 30.2744835L94.4038616 29.2514835C94.7625614 29.0443427 94.8854243 28.5856382 94.6782835 28.2269384 94.4711427 27.8682386 94.0124382 27.7453757 93.6537384 27.9525165L91.8822384 28.9755165C91.5235386 29.1826573 91.4006757 29.6413618 91.6078165 30.0000616 91.8149573 30.3587614 92.2736618 30.4816243 92.6323616 30.2744835zM97.0244835 34.1177616L98.0474835 32.3462616C98.2546243 31.9875618 98.1317614 31.5288573 97.7730616 31.3217165 97.4143618 31.1145757 96.9556573 31.2374386 96.7485165 31.5961384L95.7255165 33.3676384C95.5183757 33.7263382 95.6412386 34.1850427 95.9999384 34.3921835 96.3586382 34.5993243 96.8173427 34.4764614 97.0244835 34.1177616zM103 35.25L103 33.25C103 32.8357864 102.664214 32.5 102.25 32.5 101.835786 32.5 101.5 32.8357864 101.5 33.25L101.5 35.25C101.5 35.6642136 101.835786 36 102.25 36 102.664214 36 103 35.6642136 103 35.25zM108.274483 33.3676384L107.251483 31.5961384C107.044343 31.2374386 106.585638 31.1145757 106.226938 31.3217165 105.868239 31.5288573 105.745376 31.9875618 105.952517 32.3462616L106.975517 34.1177616C107.182657 34.4764614 107.641362 34.5993243 108.000062 34.3921835 108.358761 34.1850427 108.481624 33.7263382 108.274483 33.3676384zM112.117762 28.9755165L110.346262 27.9525165C109.987562 27.7453757 109.528857 27.8682386 109.321717 28.2269384 109.114576 28.5856382 109.237439 29.0443427 109.596138 29.2514835L111.367638 30.2744835C111.726338 30.4816243 112.185043 30.3587614 112.392183 30.0000616 112.599324 29.6413618 112.476461 29.1826573 112.117762 28.9755165zM113.25 23L111.25 23C110.835786 23 110.5 23.3357864 110.5 23.75 110.5 24.1642136 110.835786 24.5 111.25 24.5L113.25 24.5C113.664214 24.5 114 24.1642136 114 23.75 114 23.3357864 113.664214 23 113.25 23zM111.367638 17.7255165L109.596138 18.7485165C109.237439 18.9556573 109.114576 19.4143618 109.321717 19.7730616 109.528857 20.1317614 109.987562 20.2546243 110.346262 20.0474835L112.117762 19.0244835C112.476461 18.8173427 112.599324 18.3586382 112.392183 17.9999384 112.185043 17.6412386 111.726338 17.5183757 111.367638 17.7255165zM106.975517 13.8822384L105.952517 15.6537384C105.745376 16.0124382 105.868239 16.4711427 106.226938 16.6782835 106.585638 16.8854243 107.044343 16.7625614 107.251483 16.4038616L108.274483 14.6323616C108.481624 14.2736618 108.358761 13.8149573 108.000062 13.6078165 107.641362 13.4006757 107.182657 13.5235386 106.975517 13.8822384z" transform="translate(0 48)" stroke="currentColor" stroke-width="0.25"></path><path d="M98.6123,60.1372 C98.6123,59.3552 98.8753,58.6427 99.3368,58.0942 C99.5293,57.8657 99.3933,57.5092 99.0943,57.5017 C99.0793,57.5012 99.0633,57.5007 99.0483,57.5007 C97.1578,57.4747 95.5418,59.0312 95.5008,60.9217 C95.4578,62.8907 97.0408,64.5002 98.9998,64.5002 C99.7793,64.5002 100.4983,64.2452 101.0798,63.8142 C101.3183,63.6372 101.2358,63.2627 100.9478,63.1897 C99.5923,62.8457 98.6123,61.6072 98.6123,60.1372" transform="translate(3 11)"></path></g><polygon points="444 228 468 228 468 204 444 204"></polygon></g></svg></button></div><div class="flex"><a class="active:scale-95 transition-transform flex w-12 h-12 rounded-full items-center justify-center hover:bg-primary/5 hover:dark:bg-primary-dark/5 outline-link" aria-label="Translations" href="/community/translations"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d=" M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z "></path></svg></a></div><div class="flex"><a class="flex items-center justify-center w-12 h-12 transition-transform rounded-full active:scale-95 hover:bg-primary/5 hover:dark:bg-primary-dark/5 outline-link" target="_blank" rel="noreferrer noopener" aria-label="Open on GitHub" href="https://github.com/facebook/react/releases"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><g fill="currentColor"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"></path></g></svg></a></div></div></div></div></nav></div><div class="grid grid-cols-only-content lg:grid-cols-sidebar-content 2xl:grid-cols-sidebar-content-toc"><div class="lg:-mt-16 z-10"><div class="fixed top-0 py-0 shadow lg:pt-16 lg:sticky start-0 end-0 lg:shadow-none"><div class="sticky top-0 lg:bottom-0 lg:h-[calc(100vh-4rem)] flex flex-col"><div class="overflow-y-scroll no-bg-scrollbar lg:w-[342px] grow bg-wash dark:bg-wash-dark" style="overscroll-behavior:contain"><aside class="lg:grow flex-col w-full pb-8 lg:pb-0 lg:max-w-custom-xs z-10 hidden lg:block"><nav role="navigation" style="--bg-opacity:.2" class="w-full pt-6 scrolling-touch lg:h-auto grow pe-0 lg:pe-5 lg:pb-16 md:pt-4 lg:pt-4 scrolling-gpu"><!--$--><ul><h3 class="mb-1 text-sm font-bold ms-5 text-tertiary dark:text-tertiary-dark">GET STARTED</h3><li><a title="Quick Start" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between ps-5 text-base font-bold text-primary dark:text-primary-dark" href="/learn"><div>Quick Start<!-- --> </div><span class="pe-1 text-tertiary dark:text-tertiary-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition -rotate-90 rtl:rotate-90" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span></a><div class="opacity-50" style="transition:opacity 250ms ease-in-out"><div id="react-collapsed-panel-:R8im6:" aria-hidden="true" role="region" style="box-sizing:border-box;display:none;height:0px;overflow:hidden"><ul><li><a title="Tutorial: Tic-Tac-Toe" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/tutorial-tic-tac-toe"><div>Tutorial: Tic-Tac-Toe<!-- --> </div></a></li><li><a title="Thinking in React" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/thinking-in-react"><div>Thinking in React<!-- --> </div></a></li></ul></div></div></li><li><a title="Installation" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between ps-5 text-base font-bold text-primary dark:text-primary-dark" href="/learn/installation"><div>Installation<!-- --> </div><span class="pe-1 text-tertiary dark:text-tertiary-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition -rotate-90 rtl:rotate-90" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span></a><div class="opacity-50" style="transition:opacity 250ms ease-in-out"><div id="react-collapsed-panel-:R8qm6:" aria-hidden="true" role="region" style="box-sizing:border-box;display:none;height:0px;overflow:hidden"><ul><li><a title="Creating a React App" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/creating-a-react-app"><div>Creating a React App<!-- --> </div></a></li><li><a title="Build a React App from Scratch" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/build-a-react-app-from-scratch"><div>Build a React App from Scratch<!-- --> </div></a></li><li><a title="Add React to an Existing Project" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/add-react-to-an-existing-project"><div>Add React to an Existing Project<!-- --> </div></a></li></ul></div></div></li><li><a title="Setup" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between ps-5 text-base font-bold text-primary dark:text-primary-dark" href="/learn/setup"><div>Setup<!-- --> </div><span class="pe-1 text-link dark:text-link-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition rotate-0" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span></a><div class="opacity-100" style="transition:opacity 250ms ease-in-out"><div id="react-collapsed-panel-:R92m6:" aria-hidden="false" role="region" style="box-sizing:border-box"><ul><li><a title="Editor Setup" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/editor-setup"><div>Editor Setup<!-- --> </div></a></li><li><a title="Using TypeScript" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/typescript"><div>Using TypeScript<!-- --> </div></a></li><li><a title="React Developer Tools" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/react-developer-tools"><div>React Developer Tools<!-- --> </div></a></li><li><a title="React Compiler" target="" aria-current="page" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-link dark:text-link-dark bg-highlight dark:bg-highlight-dark border-blue-40 hover:bg-highlight hover:text-link dark:hover:bg-highlight-dark dark:hover:text-link-dark" href="/learn/react-compiler"><div>React Compiler<!-- --> </div></a></li></ul></div></div></li><li role="separator" class="mt-4 mb-2 ms-5 border-b border-border dark:border-border-dark"></li><h3 class="mb-1 text-sm font-bold ms-5 text-tertiary dark:text-tertiary-dark mt-2">LEARN REACT</h3><li><a title="Describing the UI" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between ps-5 text-base font-bold text-primary dark:text-primary-dark" href="/learn/describing-the-ui"><div>Describing the UI<!-- --> </div><span class="pe-1 text-tertiary dark:text-tertiary-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition -rotate-90 rtl:rotate-90" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span></a><div class="opacity-50" style="transition:opacity 250ms ease-in-out"><div id="react-collapsed-panel-:R9im6:" aria-hidden="true" role="region" style="box-sizing:border-box;display:none;height:0px;overflow:hidden"><ul><li><a title="Your First Component" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/your-first-component"><div>Your First Component<!-- --> </div></a></li><li><a title="Importing and Exporting Components" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/importing-and-exporting-components"><div>Importing and Exporting Components<!-- --> </div></a></li><li><a title="Writing Markup with JSX" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/writing-markup-with-jsx"><div>Writing Markup with JSX<!-- --> </div></a></li><li><a title="JavaScript in JSX with Curly Braces" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/javascript-in-jsx-with-curly-braces"><div>JavaScript in JSX with Curly Braces<!-- --> </div></a></li><li><a title="Passing Props to a Component" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/passing-props-to-a-component"><div>Passing Props to a Component<!-- --> </div></a></li><li><a title="Conditional Rendering" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/conditional-rendering"><div>Conditional Rendering<!-- --> </div></a></li><li><a title="Rendering Lists" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/rendering-lists"><div>Rendering Lists<!-- --> </div></a></li><li><a title="Keeping Components Pure" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/keeping-components-pure"><div>Keeping Components Pure<!-- --> </div></a></li><li><a title="Your UI as a Tree" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/understanding-your-ui-as-a-tree"><div>Your UI as a Tree<!-- --> </div></a></li></ul></div></div></li><li><a title="Adding Interactivity" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between ps-5 text-base font-bold text-primary dark:text-primary-dark" href="/learn/adding-interactivity"><div>Adding Interactivity<!-- --> </div><span class="pe-1 text-tertiary dark:text-tertiary-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition -rotate-90 rtl:rotate-90" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span></a><div class="opacity-50" style="transition:opacity 250ms ease-in-out"><div id="react-collapsed-panel-:R9qm6:" aria-hidden="true" role="region" style="box-sizing:border-box;display:none;height:0px;overflow:hidden"><ul><li><a title="Responding to Events" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/responding-to-events"><div>Responding to Events<!-- --> </div></a></li><li><a title="State: A Component's Memory" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/state-a-components-memory"><div>State: A Component's Memory<!-- --> </div></a></li><li><a title="Render and Commit" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/render-and-commit"><div>Render and Commit<!-- --> </div></a></li><li><a title="State as a Snapshot" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/state-as-a-snapshot"><div>State as a Snapshot<!-- --> </div></a></li><li><a title="Queueing a Series of State Updates" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/queueing-a-series-of-state-updates"><div>Queueing a Series of State Updates<!-- --> </div></a></li><li><a title="Updating Objects in State" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/updating-objects-in-state"><div>Updating Objects in State<!-- --> </div></a></li><li><a title="Updating Arrays in State" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/updating-arrays-in-state"><div>Updating Arrays in State<!-- --> </div></a></li></ul></div></div></li><li><a title="Managing State" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between ps-5 text-base font-bold text-primary dark:text-primary-dark" href="/learn/managing-state"><div>Managing State<!-- --> </div><span class="pe-1 text-tertiary dark:text-tertiary-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition -rotate-90 rtl:rotate-90" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span></a><div class="opacity-50" style="transition:opacity 250ms ease-in-out"><div id="react-collapsed-panel-:Ra2m6:" aria-hidden="true" role="region" style="box-sizing:border-box;display:none;height:0px;overflow:hidden"><ul><li><a title="Reacting to Input with State" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/reacting-to-input-with-state"><div>Reacting to Input with State<!-- --> </div></a></li><li><a title="Choosing the State Structure" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/choosing-the-state-structure"><div>Choosing the State Structure<!-- --> </div></a></li><li><a title="Sharing State Between Components" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/sharing-state-between-components"><div>Sharing State Between Components<!-- --> </div></a></li><li><a title="Preserving and Resetting State" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/preserving-and-resetting-state"><div>Preserving and Resetting State<!-- --> </div></a></li><li><a title="Extracting State Logic into a Reducer" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/extracting-state-logic-into-a-reducer"><div>Extracting State Logic into a Reducer<!-- --> </div></a></li><li><a title="Passing Data Deeply with Context" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/passing-data-deeply-with-context"><div>Passing Data Deeply with Context<!-- --> </div></a></li><li><a title="Scaling Up with Reducer and Context" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/scaling-up-with-reducer-and-context"><div>Scaling Up with Reducer and Context<!-- --> </div></a></li></ul></div></div></li><li><a title="Escape Hatches" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between ps-5 text-base font-bold text-primary dark:text-primary-dark" href="/learn/escape-hatches"><div>Escape Hatches<!-- --> </div><span class="pe-1 text-tertiary dark:text-tertiary-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition -rotate-90 rtl:rotate-90" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span></a><div class="opacity-50" style="transition:opacity 250ms ease-in-out"><div id="react-collapsed-panel-:Raam6:" aria-hidden="true" role="region" style="box-sizing:border-box;display:none;height:0px;overflow:hidden"><ul><li><a title="Referencing Values with Refs" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/referencing-values-with-refs"><div>Referencing Values with Refs<!-- --> </div></a></li><li><a title="Manipulating the DOM with Refs" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/manipulating-the-dom-with-refs"><div>Manipulating the DOM with Refs<!-- --> </div></a></li><li><a title="Synchronizing with Effects" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/synchronizing-with-effects"><div>Synchronizing with Effects<!-- --> </div></a></li><li><a title="You Might Not Need an Effect" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/you-might-not-need-an-effect"><div>You Might Not Need an Effect<!-- --> </div></a></li><li><a title="Lifecycle of Reactive Effects" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/lifecycle-of-reactive-effects"><div>Lifecycle of Reactive Effects<!-- --> </div></a></li><li><a title="Separating Events from Effects" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/separating-events-from-effects"><div>Separating Events from Effects<!-- --> </div></a></li><li><a title="Removing Effect Dependencies" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/removing-effect-dependencies"><div>Removing Effect Dependencies<!-- --> </div></a></li><li><a title="Reusing Logic with Custom Hooks" target="" class="p-2 pe-2 w-full rounded-none lg:rounded-e-2xl text-start hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between text-sm ps-6 ps-5 text-base text-secondary dark:text-secondary-dark" href="/learn/reusing-logic-with-custom-hooks"><div>Reusing Logic with Custom Hooks<!-- --> </div></a></li></ul></div></div></li></ul><!--/$--><div class="h-20"></div></nav><div class="fixed bottom-0 hidden lg:block"><div class="max-w-custom-xs w-80 lg:w-auto py-3 shadow-lg rounded-lg m-4 bg-wash dark:bg-gray-95 px-4 flex"><p class="w-full text-lg font-bold text-primary dark:text-primary-dark me-4">Is this page useful?</p><button aria-label="Yes" class="px-3 rounded-lg bg-secondary-button dark:bg-secondary-button-dark text-primary dark:text-primary-dark me-2"><svg width="16" height="18" viewBox="0 0 16 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M9.36603 0.384603C9.36605 0.384617 9.36601 0.384588 9.36603 0.384603L9.45902 0.453415C9.99732 0.851783 10.3873 1.42386 10.5654 2.07648C10.7435 2.72909 10.6993 3.42385 10.44 4.04763L9.27065 6.86008H12.6316C13.5249 6.86008 14.3817 7.22121 15.0134 7.86402C15.6451 8.50683 16 9.37868 16 10.2877V13.7154C16 14.8518 15.5564 15.9416 14.7668 16.7451C13.9771 17.5486 12.9062 18 11.7895 18H5.05263C3.71259 18 2.42743 17.4583 1.47988 16.4941C0.532325 15.5299 0 14.2221 0 12.8585V11.2511C2.40928e-06 9.87711 0.463526 8.54479 1.31308 7.47688L6.66804 0.745592C6.98662 0.345136 7.44414 0.08434 7.94623 0.0171605C8.4483 -0.0500155 8.95656 0.0815891 9.36603 0.384603ZM8.37542 1.77064C8.31492 1.72587 8.23987 1.70646 8.16579 1.71637C8.09171 1.72628 8.02415 1.76477 7.97708 1.82393L2.62213 8.55522C2.0153 9.31801 1.68421 10.2697 1.68421 11.2511V12.8585C1.68421 13.7676 2.03909 14.6394 2.67079 15.2822C3.30249 15.925 4.15927 16.2862 5.05263 16.2862H11.7895C12.4595 16.2862 13.1021 16.0153 13.5759 15.5332C14.0496 15.0511 14.3158 14.3972 14.3158 13.7154V10.2877C14.3158 9.83321 14.1383 9.39729 13.8225 9.07588C13.5066 8.75448 13.0783 8.57392 12.6316 8.57392H8C7.71763 8.57392 7.45405 8.4299 7.29806 8.19039C7.14206 7.95087 7.11442 7.64774 7.22445 7.38311L8.88886 3.37986C9 3.11253 9.01896 2.81477 8.94262 2.53507C8.8663 2.25541 8.69921 2.01027 8.46853 1.83954L8.37542 1.77064Z" fill="currentColor"></path></svg></button><button aria-label="No" class="px-3 rounded-lg bg-secondary-button dark:bg-secondary-button-dark text-primary dark:text-primary-dark"><svg width="16" height="18" viewBox="0 0 16 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.63397 17.6154C6.63395 17.6154 6.63399 17.6154 6.63397 17.6154L6.54098 17.5466C6.00268 17.1482 5.61269 16.5761 5.43458 15.9235C5.25648 15.2709 5.30069 14.5761 5.56004 13.9524L6.72935 11.1399L3.36842 11.1399C2.47506 11.1399 1.61829 10.7788 0.986585 10.136C0.354883 9.49316 8.1991e-07 8.62132 8.99384e-07 7.71225L1.19904e-06 4.28458C1.29838e-06 3.14824 0.443605 2.05844 1.23323 1.25492C2.02286 0.451403 3.09383 -1.12829e-06 4.21053 -1.03067e-06L10.9474 -4.41715e-07C12.2874 -3.24565e-07 13.5726 0.541687 14.5201 1.50591C15.4677 2.47013 16 3.77789 16 5.1415L16 6.74893C16 8.12289 15.5365 9.45521 14.6869 10.5231L9.33196 17.2544C9.01338 17.6549 8.55586 17.9157 8.05377 17.9828C7.5517 18.05 7.04344 17.9184 6.63397 17.6154ZM7.62458 16.2294C7.68508 16.2741 7.76013 16.2935 7.83421 16.2836C7.90829 16.2737 7.97585 16.2352 8.02292 16.1761L13.3779 9.44478C13.9847 8.68199 14.3158 7.73033 14.3158 6.74892L14.3158 5.1415C14.3158 4.23242 13.9609 3.36058 13.3292 2.71777C12.6975 2.07496 11.8407 1.71383 10.9474 1.71383L4.21053 1.71383C3.5405 1.71383 2.89793 1.98468 2.42415 2.46679C1.95038 2.94889 1.68421 3.60277 1.68421 4.28458L1.68421 7.71225C1.68421 8.16679 1.86166 8.60271 2.1775 8.92411C2.49335 9.24552 2.92174 9.42608 3.36842 9.42608L8 9.42608C8.28237 9.42608 8.54595 9.5701 8.70195 9.80961C8.85794 10.0491 8.88558 10.3523 8.77555 10.6169L7.11114 14.6201C7 14.8875 6.98105 15.1852 7.05738 15.4649C7.1337 15.7446 7.30079 15.9897 7.53147 16.1605L7.62458 16.2294Z" fill="currentColor"></path></svg></button></div></div></aside></div></div></div></div><!--$--><main class="min-w-0 isolate"><article class="font-normal break-words text-primary dark:text-primary-dark"><div class="ps-0"><div class=""><div class="px-5 sm:px-12 pt-3.5"><div class="max-w-4xl ms-0 2xl:mx-auto"><div class="flex flex-wrap"><div class="flex mb-3 mt-0.5 items-center"><a class="text-link dark:text-link-dark text-sm tracking-wide font-bold uppercase me-1 hover:underline" href="/learn">Learn React</a><span class="inline-block me-1 text-link dark:text-link-dark text-lg rtl:rotate-180"><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.86612 13.6161C6.37796 14.1043 6.37796 14.8957 6.86612 15.3839C7.35427 15.872 8.14572 15.872 8.63388 15.3839L13.1339 10.8839C13.622 10.3957 13.622 9.60428 13.1339 9.11612L8.63388 4.61612C8.14572 4.12797 7.35427 4.12797 6.86612 4.61612C6.37796 5.10428 6.37796 5.89573 6.86612 6.38388L10.4822 10L6.86612 13.6161Z" fill="currentColor"></path></svg></span></div><div class="flex mb-3 mt-0.5 items-center"><a class="text-link dark:text-link-dark text-sm tracking-wide font-bold uppercase me-1 hover:underline" href="/learn/setup">Setup</a><span class="inline-block me-1 text-link dark:text-link-dark text-lg rtl:rotate-180"><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.86612 13.6161C6.37796 14.1043 6.37796 14.8957 6.86612 15.3839C7.35427 15.872 8.14572 15.872 8.63388 15.3839L13.1339 10.8839C13.622 10.3957 13.622 9.60428 13.1339 9.11612L8.63388 4.61612C8.14572 4.12797 7.35427 4.12797 6.86612 4.61612C6.37796 5.10428 6.37796 5.89573 6.86612 6.38388L10.4822 10L6.86612 13.6161Z" fill="currentColor"></path></svg></span></div></div><h1 class="mdx-heading mt-0 text-primary dark:text-primary-dark -mx-.5 break-words text-5xl font-display font-bold leading-tight">React Compiler<a href="#undefined" aria-label="Link for this heading" title="Link for this heading" class="mdx-header-anchor hidden"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h1></div></div></div><div class="px-5 sm:px-12"><div class="max-w-7xl mx-auto"><div class="max-w-4xl ms-0 2xl:mx-auto"><div class="font-display text-xl text-primary dark:text-primary-dark leading-relaxed"><p class="whitespace-pre-wrap my-4">This page will give you an introduction to React Compiler and how to try it out successfully.</p></div> <div class="expandable-callout pt-8 pb-4 px-5 sm:px-8 my-8 relative rounded-none shadow-inner-border -mx-5 sm:mx-auto sm:rounded-2xl bg-yellow-5 dark:bg-yellow-60 dark:bg-opacity-20"><h3 class="text-2xl font-display font-bold text-yellow-50 dark:text-yellow-40"><svg class="inline me-2 mb-1 text-lg text-yellow-50 dark:text-yellow-40" width="2em" height="2em" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_40_48064)"><path d="M24 27C24 25.3431 25.3431 24 27 24H45C46.6569 24 48 25.3431 48 27C48 28.6569 46.6569 30 45 30H27C25.3431 30 24 28.6569 24 27Z" fill="currentColor"></path><path d="M24 39C24 37.3431 25.3431 36 27 36H39C40.6569 36 42 37.3431 42 39C42 40.6569 40.6569 42 39 42H27C25.3431 42 24 40.6569 24 39Z" fill="currentColor"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M12 18C12 13.0294 16.0294 9 21 9H51C55.9706 9 60 13.0294 60 18V54C60 58.9706 55.9706 63 51 63H21C16.0294 63 12 58.9706 12 54V18ZM21 15H51C52.6569 15 54 16.3431 54 18V54C54 55.6569 52.6569 57 51 57H21C19.3431 57 18 55.6569 18 54V18C18 16.3431 19.3431 15 21 15Z" fill="currentColor"></path></g><defs><clipPath id="clip0_40_48064"><rect width="72" height="72" fill="white"></rect></clipPath></defs></svg>Under Construction</h3><div class="relative"><div class="py-2"><p class="whitespace-pre-wrap my-4">These docs are still a work in progress. More documentation is available in the <a href="https://github.com/reactwg/react-compiler/discussions" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">React Compiler Working Group repo</a>, and will be upstreamed into these docs when they are more stable.</p></div></div></div> <div class="p-6 xl:p-8 pb-4 xl:pb-6 bg-card dark:bg-card-dark rounded-2xl shadow-inner-border dark:shadow-inner-border-dark text-base text-secondary dark:text-secondary-dark my-8"><h3 class="mdx-heading text-primary dark:text-primary-dark mt-0 mb-3 leading-tight text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">You will learn</h3><ul class="ms-6 my-3 list-disc"> <li class="leading-relaxed mb-1">Getting started with the compiler</li> <li class="leading-relaxed mb-1">Installing the compiler and ESLint plugin</li> <li class="leading-relaxed mb-1">Troubleshooting</li> </ul></div> <div class="expandable-callout pt-8 pb-4 px-5 sm:px-8 my-8 relative rounded-none shadow-inner-border -mx-5 sm:mx-auto sm:rounded-2xl bg-green-5 dark:bg-green-60 dark:bg-opacity-20 text-primary dark:text-primary-dark text-lg"><h3 class="text-2xl font-display font-bold text-green-60 dark:text-green-40"><svg class="inline me-2 mb-1 text-lg text-green-60 dark:text-green-40" width="2em" height="2em" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_40_48064)"><path d="M24 27C24 25.3431 25.3431 24 27 24H45C46.6569 24 48 25.3431 48 27C48 28.6569 46.6569 30 45 30H27C25.3431 30 24 28.6569 24 27Z" fill="currentColor"></path><path d="M24 39C24 37.3431 25.3431 36 27 36H39C40.6569 36 42 37.3431 42 39C42 40.6569 40.6569 42 39 42H27C25.3431 42 24 40.6569 24 39Z" fill="currentColor"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M12 18C12 13.0294 16.0294 9 21 9H51C55.9706 9 60 13.0294 60 18V54C60 58.9706 55.9706 63 51 63H21C16.0294 63 12 58.9706 12 54V18ZM21 15H51C52.6569 15 54 16.3431 54 18V54C54 55.6569 52.6569 57 51 57H21C19.3431 57 18 55.6569 18 54V18C18 16.3431 19.3431 15 21 15Z" fill="currentColor"></path></g><defs><clipPath id="clip0_40_48064"><rect width="72" height="72" fill="white"></rect></clipPath></defs></svg>Note</h3><div class="relative"><div class="py-2"><p class="whitespace-pre-wrap my-4">React Compiler is a new compiler currently in Beta, that we’ve open sourced to get early feedback from the community. While it has been used in production at companies like Meta, rolling out the compiler to production for your app will depend on the health of your codebase and how well you’ve followed the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="/reference/rules">Rules of React</a>.</p><p class="whitespace-pre-wrap my-4">The latest Beta release can be found with the <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">@beta</code> tag, and daily experimental releases with <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">@experimental</code>.</p></div></div></div> <p class="whitespace-pre-wrap my-4">React Compiler is a new compiler that we’ve open sourced to get early feedback from the community. It is a build-time only tool that automatically optimizes your React app. It works with plain JavaScript, and understands the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="/reference/rules">Rules of React</a>, so you don’t need to rewrite any code to use it.</p> <p class="whitespace-pre-wrap my-4">The compiler also includes an <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="#installing-eslint-plugin-react-compiler">ESLint plugin</a> that surfaces the analysis from the compiler right in your editor. <strong class="font-bold">We strongly recommend everyone use the linter today.</strong> The linter does not require that you have the compiler installed, so you can use it even if you are not ready to try out the compiler.</p> <p class="whitespace-pre-wrap my-4">The compiler is currently released as <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">beta</code>, and is available to try out on React 17+ apps and libraries. To install the Beta:</p> <div class="rounded-lg bg-secondary dark:bg-gray-50 h-full"><div class="bg-gray-90 dark:bg-gray-60 w-full rounded-t-lg"><div class="text-primary-dark dark:text-primary-dark flex text-sm px-4 py-0.5 relative justify-between"><div><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.40299 2.61279H14.403C14.5798 2.61279 14.7494 2.68303 14.8744 2.80806C14.9994 2.93308 15.0697 3.10265 15.0697 3.27946V13.9461C15.0697 14.1229 14.9994 14.2925 14.8744 14.4175C14.7494 14.5426 14.5798 14.6128 14.403 14.6128H2.40299C2.22618 14.6128 2.05661 14.5426 1.93159 14.4175C1.80657 14.2925 1.73633 14.1229 1.73633 13.9461V3.27946C1.73633 3.10265 1.80657 2.93308 1.93159 2.80806C2.05661 2.68303 2.22618 2.61279 2.40299 2.61279ZM8.403 10.6128V11.9461H12.403V10.6128H8.403ZM6.01233 8.61279L4.12699 10.4981L5.06966 11.4415L7.89833 8.61279L5.06966 5.78413L4.12699 6.72746L6.01233 8.61279Z" fill="currentColor"></path></svg> Terminal</div><div><button class="w-full text-start text-primary-dark dark:text-primary-dark "><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.40382 15.3671C5.03332 15.1901 4.70081 14.9381 4.42481 14.6286C4.34831 14.5431 4.23931 14.5001 4.12981 14.5206L3.66181 14.6081C3.33531 14.6691 3.02032 14.4361 2.96232 14.0876L1.30981 4.12512C1.28181 3.95662 1.31731 3.7861 1.40981 3.6456C1.50231 3.5051 1.64082 3.41162 1.79932 3.38162L3.22131 3.00012C3.37681 2.97062 3.48981 2.82761 3.48981 2.65961V1.9101C3.48981 1.8276 3.49381 1.74561 3.49931 1.66461C3.50931 1.53461 3.35181 1.57211 3.35181 1.57211L1.64381 2.0076C1.18481 2.0936 0.751316 2.32662 0.451316 2.70612C0.0808162 3.17362 -0.0686885 3.77259 0.0293115 4.36459L1.68231 14.3281C1.84531 15.3081 2.65031 16.0001 3.55631 16.0001C3.66531 16.0001 3.77631 15.9896 3.88731 15.9691L5.36632 15.6916C5.52332 15.6626 5.54982 15.4366 5.40382 15.3671ZM14.9331 4.55801H12.9116C12.1351 4.55801 11.5001 3.91502 11.5001 3.12952V1.06802C11.5001 0.480524 11.0196 0 10.4321 0H7.44161C6.36911 0 5.50011 0.879508 5.50011 1.96451V12.1665C5.50011 13.179 6.33412 14 7.36262 14H14.1371C15.1661 14 16.0001 13.179 16.0001 12.1665V5.625C16.0001 5.038 15.5201 4.55801 14.9331 4.55801Z" fill="currentColor"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5888 0.0914385C12.4493 0.00843847 12.5158 0.252449 12.5158 0.252449C12.5653 0.428449 12.5918 0.613451 12.5918 0.804451V2.90296C12.5918 3.17646 12.8158 3.40046 13.0903 3.40046H15.1718C15.3883 3.40046 15.5968 3.43495 15.7918 3.49845C15.7918 3.49845 15.9373 3.50844 15.9008 3.43494C15.8383 3.33744 15.7673 3.24494 15.6833 3.16044L12.8303 0.289467C12.7558 0.214467 12.6743 0.149438 12.5888 0.0914385Z" fill="currentColor"></path></svg> <!-- -->Copy</button></div></div></div><div class="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-auto" translate="no" dir="ltr">npm install -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta</div></div> <p class="whitespace-pre-wrap my-4">Or, if you’re using Yarn:</p> <div class="rounded-lg bg-secondary dark:bg-gray-50 h-full"><div class="bg-gray-90 dark:bg-gray-60 w-full rounded-t-lg"><div class="text-primary-dark dark:text-primary-dark flex text-sm px-4 py-0.5 relative justify-between"><div><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.40299 2.61279H14.403C14.5798 2.61279 14.7494 2.68303 14.8744 2.80806C14.9994 2.93308 15.0697 3.10265 15.0697 3.27946V13.9461C15.0697 14.1229 14.9994 14.2925 14.8744 14.4175C14.7494 14.5426 14.5798 14.6128 14.403 14.6128H2.40299C2.22618 14.6128 2.05661 14.5426 1.93159 14.4175C1.80657 14.2925 1.73633 14.1229 1.73633 13.9461V3.27946C1.73633 3.10265 1.80657 2.93308 1.93159 2.80806C2.05661 2.68303 2.22618 2.61279 2.40299 2.61279ZM8.403 10.6128V11.9461H12.403V10.6128H8.403ZM6.01233 8.61279L4.12699 10.4981L5.06966 11.4415L7.89833 8.61279L5.06966 5.78413L4.12699 6.72746L6.01233 8.61279Z" fill="currentColor"></path></svg> Terminal</div><div><button class="w-full text-start text-primary-dark dark:text-primary-dark "><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.40382 15.3671C5.03332 15.1901 4.70081 14.9381 4.42481 14.6286C4.34831 14.5431 4.23931 14.5001 4.12981 14.5206L3.66181 14.6081C3.33531 14.6691 3.02032 14.4361 2.96232 14.0876L1.30981 4.12512C1.28181 3.95662 1.31731 3.7861 1.40981 3.6456C1.50231 3.5051 1.64082 3.41162 1.79932 3.38162L3.22131 3.00012C3.37681 2.97062 3.48981 2.82761 3.48981 2.65961V1.9101C3.48981 1.8276 3.49381 1.74561 3.49931 1.66461C3.50931 1.53461 3.35181 1.57211 3.35181 1.57211L1.64381 2.0076C1.18481 2.0936 0.751316 2.32662 0.451316 2.70612C0.0808162 3.17362 -0.0686885 3.77259 0.0293115 4.36459L1.68231 14.3281C1.84531 15.3081 2.65031 16.0001 3.55631 16.0001C3.66531 16.0001 3.77631 15.9896 3.88731 15.9691L5.36632 15.6916C5.52332 15.6626 5.54982 15.4366 5.40382 15.3671ZM14.9331 4.55801H12.9116C12.1351 4.55801 11.5001 3.91502 11.5001 3.12952V1.06802C11.5001 0.480524 11.0196 0 10.4321 0H7.44161C6.36911 0 5.50011 0.879508 5.50011 1.96451V12.1665C5.50011 13.179 6.33412 14 7.36262 14H14.1371C15.1661 14 16.0001 13.179 16.0001 12.1665V5.625C16.0001 5.038 15.5201 4.55801 14.9331 4.55801Z" fill="currentColor"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5888 0.0914385C12.4493 0.00843847 12.5158 0.252449 12.5158 0.252449C12.5653 0.428449 12.5918 0.613451 12.5918 0.804451V2.90296C12.5918 3.17646 12.8158 3.40046 13.0903 3.40046H15.1718C15.3883 3.40046 15.5968 3.43495 15.7918 3.49845C15.7918 3.49845 15.9373 3.50844 15.9008 3.43494C15.8383 3.33744 15.7673 3.24494 15.6833 3.16044L12.8303 0.289467C12.7558 0.214467 12.6743 0.149438 12.5888 0.0914385Z" fill="currentColor"></path></svg> <!-- -->Copy</button></div></div></div><div class="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-auto" translate="no" dir="ltr">yarn add -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta</div></div> <p class="whitespace-pre-wrap my-4">If you are not using React 19 yet, please see <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="#using-react-compiler-with-react-17-or-18">the section below</a> for further instructions.</p> <h3 id="what-does-the-compiler-do" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">What does the compiler do? <a href="#what-does-the-compiler-do" aria-label="Link for What does the compiler do? " title="Link for What does the compiler do? " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">In order to optimize applications, React Compiler automatically memoizes your code. You may be familiar today with memoization through APIs such as <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">useMemo</code>, <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">useCallback</code>, and <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">React.memo</code>. With these APIs you can tell React that certain parts of your application don’t need to recompute if their inputs haven’t changed, reducing work on updates. While powerful, it’s easy to forget to apply memoization or apply them incorrectly. This can lead to inefficient updates as React has to check parts of your UI that don’t have any <em>meaningful</em> changes.</p> <p class="whitespace-pre-wrap my-4">The compiler uses its knowledge of JavaScript and React’s rules to automatically memoize values or groups of values within your components and hooks. If it detects breakages of the rules, it will automatically skip over just those components or hooks, and continue safely compiling other code.</p> <div class="expandable-callout pt-8 pb-4 px-5 sm:px-8 my-8 relative rounded-none shadow-inner-border -mx-5 sm:mx-auto sm:rounded-2xl bg-green-5 dark:bg-green-60 dark:bg-opacity-20 text-primary dark:text-primary-dark text-lg"><h3 class="text-2xl font-display font-bold text-green-60 dark:text-green-40"><svg class="inline me-2 mb-1 text-lg text-green-60 dark:text-green-40" width="2em" height="2em" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_40_48064)"><path d="M24 27C24 25.3431 25.3431 24 27 24H45C46.6569 24 48 25.3431 48 27C48 28.6569 46.6569 30 45 30H27C25.3431 30 24 28.6569 24 27Z" fill="currentColor"></path><path d="M24 39C24 37.3431 25.3431 36 27 36H39C40.6569 36 42 37.3431 42 39C42 40.6569 40.6569 42 39 42H27C25.3431 42 24 40.6569 24 39Z" fill="currentColor"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M12 18C12 13.0294 16.0294 9 21 9H51C55.9706 9 60 13.0294 60 18V54C60 58.9706 55.9706 63 51 63H21C16.0294 63 12 58.9706 12 54V18ZM21 15H51C52.6569 15 54 16.3431 54 18V54C54 55.6569 52.6569 57 51 57H21C19.3431 57 18 55.6569 18 54V18C18 16.3431 19.3431 15 21 15Z" fill="currentColor"></path></g><defs><clipPath id="clip0_40_48064"><rect width="72" height="72" fill="white"></rect></clipPath></defs></svg>Note</h3><div class="relative"><div class="py-2"><p class="whitespace-pre-wrap my-4">React Compiler can statically detect when Rules of React are broken, and safely opt-out of optimizing just the affected components or hooks. It is not necessary for the compiler to optimize 100% of your codebase.</p></div></div></div> <p class="whitespace-pre-wrap my-4">If your codebase is already very well-memoized, you might not expect to see major performance improvements with the compiler. However, in practice memoizing the correct dependencies that cause performance issues is tricky to get right by hand.</p> <details class="my-12 rounded-2xl shadow-inner-border dark:shadow-inner-border-dark relative dark:bg-opacity-20 dark:bg-purple-60 bg-purple-5"><summary class="list-none p-8" tabindex="-1"><h5 class="mb-4 uppercase font-bold flex items-center text-sm dark:text-purple-30 text-purple-50"><svg class="inline me-2 dark:text-purple-30 text-purple-40" width="1.5em" height="1.5em" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M34.7409 59.7228L32.9567 58.9094C27.2672 56.3157 20.7328 56.3157 15.0433 58.9094C12.6018 60.0224 9.39163 59.0275 8.44602 56.0621C7.45647 52.9589 5.99975 46.5898 6 35.9997C6.00029 23.5648 8.00803 18.3599 9.11099 16.4196C9.67795 15.4222 10.5255 14.8455 11.2254 14.5264L12.0179 14.1651C19.6351 10.6926 28.4011 10.6738 36 14.1733C43.5989 10.6738 52.3649 10.6926 59.9821 14.1651L60.7746 14.5264C61.4745 14.8455 62.3221 15.4222 62.889 16.4196C63.992 18.3599 65.9997 23.5648 66 35.9997C66.0002 46.5898 64.5435 52.9589 63.554 56.0621C62.6084 59.0275 59.3982 60.0224 56.9567 58.9094C51.2672 56.3157 44.7328 56.3157 39.0433 58.9094L37.2591 59.7228C37.1986 59.7508 37.1373 59.7767 37.0753 59.8004C36.4484 60.0411 35.7556 60.0653 35.1102 59.8648C34.9847 59.8258 34.8613 59.7784 34.7409 59.7228ZM14.5068 19.6246C20.3733 16.9501 27.0874 16.8775 33 19.4067V52.473C26.7613 50.32 19.9378 50.471 13.7811 52.9261C13.0005 49.9843 11.9998 44.547 12 35.9998C12.0002 25.5786 13.4879 21.1893 14.1179 19.8018L14.5068 19.6246ZM39 52.473C45.2387 50.32 52.0622 50.471 58.2189 52.9261C58.9995 49.9843 60.0002 44.547 60 35.9998C59.9998 25.5786 58.5121 21.1893 57.8821 19.8018L57.4932 19.6246C51.6267 16.9501 44.9126 16.8775 39 19.4067V52.473Z" fill="currentColor"></path></svg>Deep Dive</h5><div class="mb-4"><h4 id="what-kind-of-memoization-does-react-compiler-add" class="mdx-heading text-xl font-bold text-primary dark:text-primary-dark text-xl font-display font-bold leading-9 my-4">What kind of memoization does React Compiler add? <a href="#what-kind-of-memoization-does-react-compiler-add" aria-label="Link for What kind of memoization does React Compiler add? " title="Link for What kind of memoization does React Compiler add? " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h4></div><button class="bg-purple-50 border-purple-50 hover:bg-purple-40 focus:bg-purple-50 active:bg-purple-50 text-base leading-tight font-bold rounded-full py-2 px-4 focus:outline focus:outline-offset-2 focus:outline-link dark:focus:outline-link-dark inline-flex items-center my-1 bg-link border-link text-white hover:bg-link focus:bg-link active:bg-link"><span class="me-1"><svg class="rotate-0" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg></span>Show Details</button></summary><div class="p-8 border-t dark:border-purple-60 border-purple-10 "><p class="whitespace-pre-wrap my-4">The initial release of React Compiler is primarily focused on <strong class="font-bold">improving update performance</strong> (re-rendering existing components), so it focuses on these two use cases:</p><ol class="ms-6 my-3 list-decimal"> <li class="leading-relaxed mb-1"><strong class="font-bold">Skipping cascading re-rendering of components</strong> <ul class="ms-6 my-3 list-disc"> <li class="leading-relaxed mb-1">Re-rendering <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px"><Parent /></code> causes many components in its component tree to re-render, even though only <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px"><Parent /></code> has changed</li> </ul> </li> <li class="leading-relaxed mb-1"><strong class="font-bold">Skipping expensive calculations from outside of React</strong> <ul class="ms-6 my-3 list-disc"> <li class="leading-relaxed mb-1">For example, calling <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">expensivelyProcessAReallyLargeArrayOfObjects()</code> inside of your component or hook that needs that data</li> </ul> </li> </ol><h4 id="optimizing-re-renders" class="mdx-heading text-xl font-display font-bold leading-9 my-4">Optimizing Re-renders <a href="#optimizing-re-renders" aria-label="Link for Optimizing Re-renders " title="Link for Optimizing Re-renders " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h4><p class="whitespace-pre-wrap my-4">React lets you express your UI as a function of their current state (more concretely: their props, state, and context). In its current implementation, when a component’s state changes, React will re-render that component <em>and all of its children</em> — unless you have applied some form of manual memoization with <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">useMemo()</code>, <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">useCallback()</code>, or <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">React.memo()</code>. For example, in the following example, <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px"><MessageButton></code> will re-render whenever <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px"><FriendList></code>’s state changes:</p><!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-keyword">function</span> <span class="sp-syntax-definition">FriendList</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">{</span> <span class="sp-syntax-property">friends</span> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">const</span> <span class="sp-syntax-plain">onlineCount</span> = <span class="sp-syntax-definition">useFriendOnlineCount</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">if</span> <span class="sp-syntax-punctuation">(</span><span class="sp-syntax-plain">friends</span>.<span class="sp-syntax-property">length</span> === <span class="sp-syntax-static">0</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">return</span> <span class="sp-syntax-punctuation"><</span><span class="sp-syntax-definition">NoFriends</span> <span class="sp-syntax-punctuation">/></span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">return</span> <span class="sp-syntax-punctuation">(</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation"><</span><span class="sp-syntax-tag">div</span><span class="sp-syntax-punctuation">></span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation"><</span><span class="sp-syntax-tag">span</span><span class="sp-syntax-punctuation">></span><span class="sp-syntax-punctuation">{</span><span class="sp-syntax-plain">onlineCount</span><span class="sp-syntax-punctuation">}</span> online<span class="sp-syntax-punctuation"></</span><span class="sp-syntax-tag">span</span><span class="sp-syntax-punctuation">></span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">{</span><span class="sp-syntax-plain">friends</span>.<span class="sp-syntax-property">map</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-plain">friend</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">=></span> <span class="sp-syntax-punctuation">(</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation"><</span><span class="sp-syntax-definition">FriendListCard</span> <span class="sp-syntax-property">key</span>=<span class="sp-syntax-punctuation">{</span><span class="sp-syntax-plain">friend</span>.<span class="sp-syntax-property">id</span><span class="sp-syntax-punctuation">}</span> <span class="sp-syntax-property">friend</span>=<span class="sp-syntax-punctuation">{</span><span class="sp-syntax-plain">friend</span><span class="sp-syntax-punctuation">}</span> <span class="sp-syntax-punctuation">/></span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">}</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation"><</span><span class="sp-syntax-definition">MessageButton</span> <span class="sp-syntax-punctuation">/></span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation"></</span><span class="sp-syntax-tag">div</span><span class="sp-syntax-punctuation">></span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span></div></code></pre></div></div></div></div><!--/$--><p class="whitespace-pre-wrap my-4"><a href="https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAYjHgpgCYAyeYOAFMEWuZVWEQL4CURwADrEicQgyKEANnkwIAwtEw4iAXiJQwCMhWoB5TDLmKsTXgG5hRInjRFGbXZwB0UygHMcACzWr1ABn4hEWsYBBxYYgAeADkIHQ4uAHoAPksRbisiMIiYYkYs6yiqPAA3FMLrIiiwAAcAQ0wU4GlZBSUcbklDNqikusaKkKrgR0TnAFt62sYHdmp+VRT7SqrqhOo6Bnl6mCoiAGsEAE9VUfmqZzwqLrHqM7ubolTVol5eTOGigFkEMDB6u4EAAhKA4HCEZ5DNZ9ErlLIWYTcEDcIA" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal"><em>See this example in the React Compiler Playground</em></a></p><p class="whitespace-pre-wrap my-4">React Compiler automatically applies the equivalent of manual memoization, ensuring that only the relevant parts of an app re-render as state changes, which is sometimes referred to as “fine-grained reactivity”. In the above example, React Compiler determines that the return value of <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px"><FriendListCard /></code> can be reused even as <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">friends</code> changes, and can avoid recreating this JSX <em>and</em> avoid re-rendering <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px"><MessageButton></code> as the count changes.</p><h4 id="expensive-calculations-also-get-memoized" class="mdx-heading text-xl font-display font-bold leading-9 my-4">Expensive calculations also get memoized <a href="#expensive-calculations-also-get-memoized" aria-label="Link for Expensive calculations also get memoized " title="Link for Expensive calculations also get memoized " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h4><p class="whitespace-pre-wrap my-4">The compiler can also automatically memoize for expensive calculations used during rendering:</p><!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-comment">// **Not** memoized by React Compiler, since this is not a component or hook</span><br/></div><div class="cm-line "><span class="sp-syntax-keyword">function</span> <span class="sp-syntax-definition">expensivelyProcessAReallyLargeArrayOfObjects</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">{</span> <span class="sp-syntax-comment">/* ... */</span> <span class="sp-syntax-punctuation">}</span><br/></div><div class="cm-line "><br/></div><div class="cm-line "><span class="sp-syntax-comment">// Memoized by React Compiler since this is a component</span><br/></div><div class="cm-line "><span class="sp-syntax-keyword">function</span> <span class="sp-syntax-definition">TableContainer</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">{</span> <span class="sp-syntax-property">items</span> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-comment">// This function call would be memoized:</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">const</span> <span class="sp-syntax-plain">data</span> = <span class="sp-syntax-definition">expensivelyProcessAReallyLargeArrayOfObjects</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-plain">items</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "> <span class="sp-syntax-comment">// ...</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span></div></code></pre></div></div></div></div><!--/$--><p class="whitespace-pre-wrap my-4"><a href="https://playground.react.dev/#N4Igzg9grgTgxgUxALhAejQAgFTYHIQAuumAtgqRAJYBeCAJpgEYCemASggIZyGYDCEUgAcqAGwQwANJjBUAdokyEAFlTCZ1meUUxdMcIcIjyE8vhBiYVECAGsAOvIBmURYSonMCAB7CzcgBuCGIsAAowEIhgYACCnFxioQAyXDAA5gixMDBcLADyzvlMAFYIvGAAFACUmMCYaNiYAHStOFgAvk5OGJgAshTUdIysHNy8AkbikrIKSqpaWvqGIiZmhE6u7p7ymAAqXEwSguZcCpKV9VSEFBodtcBOmAYmYHz0XIT6ALzefgFUYKhCJRBAxeLcJIsVIZLI5PKFYplCqVa63aoAbm6u0wMAQhFguwAPPRAQA+YAfL4dIloUmBMlODogDpAA" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal"><em>See this example in the React Compiler Playground</em></a></p><p class="whitespace-pre-wrap my-4">However, if <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">expensivelyProcessAReallyLargeArrayOfObjects</code> is truly an expensive function, you may want to consider implementing its own memoization outside of React, because:</p><ul class="ms-6 my-3 list-disc"> <li class="leading-relaxed mb-1">React Compiler only memoizes React components and hooks, not every function</li> <li class="leading-relaxed mb-1">React Compiler’s memoization is not shared across multiple components or hooks</li> </ul><p class="whitespace-pre-wrap my-4">So if <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">expensivelyProcessAReallyLargeArrayOfObjects</code> was used in many different components, even if the same exact items were passed down, that expensive calculation would be run repeatedly. We recommend <a href="https://react.dev/reference/react/useMemo#how-to-tell-if-a-calculation-is-expensive" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">profiling</a> first to see if it really is that expensive before making code more complicated.</p></div></details> <h3 id="should-i-try-out-the-compiler" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Should I try out the compiler? <a href="#should-i-try-out-the-compiler" aria-label="Link for Should I try out the compiler? " title="Link for Should I try out the compiler? " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">Please note that the compiler is still in Beta and has many rough edges. While it has been used in production at companies like Meta, rolling out the compiler to production for your app will depend on the health of your codebase and how well you’ve followed the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="/reference/rules">Rules of React</a>.</p> <p class="whitespace-pre-wrap my-4"><strong class="font-bold">You don’t have to rush into using the compiler now. It’s okay to wait until it reaches a stable release before adopting it.</strong> However, we do appreciate trying it out in small experiments in your apps so that you can <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="#reporting-issues">provide feedback</a> to us to help make the compiler better.</p> <h2 id="getting-started" class="mdx-heading text-3xl font-display leading-10 text-primary dark:text-primary-dark font-bold my-6">Getting Started <a href="#getting-started" aria-label="Link for Getting Started " title="Link for Getting Started " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h2> <p class="whitespace-pre-wrap my-4">In addition to these docs, we recommend checking the <a href="https://github.com/reactwg/react-compiler" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">React Compiler Working Group</a> for additional information and discussion about the compiler.</p> <h3 id="installing-eslint-plugin-react-compiler" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Installing eslint-plugin-react-compiler <a href="#installing-eslint-plugin-react-compiler" aria-label="Link for Installing eslint-plugin-react-compiler " title="Link for Installing eslint-plugin-react-compiler " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">React Compiler also powers an ESLint plugin. The ESLint plugin can be used <strong class="font-bold">independently</strong> of the compiler, meaning you can use the ESLint plugin even if you don’t use the compiler.</p> <div class="rounded-lg bg-secondary dark:bg-gray-50 h-full"><div class="bg-gray-90 dark:bg-gray-60 w-full rounded-t-lg"><div class="text-primary-dark dark:text-primary-dark flex text-sm px-4 py-0.5 relative justify-between"><div><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.40299 2.61279H14.403C14.5798 2.61279 14.7494 2.68303 14.8744 2.80806C14.9994 2.93308 15.0697 3.10265 15.0697 3.27946V13.9461C15.0697 14.1229 14.9994 14.2925 14.8744 14.4175C14.7494 14.5426 14.5798 14.6128 14.403 14.6128H2.40299C2.22618 14.6128 2.05661 14.5426 1.93159 14.4175C1.80657 14.2925 1.73633 14.1229 1.73633 13.9461V3.27946C1.73633 3.10265 1.80657 2.93308 1.93159 2.80806C2.05661 2.68303 2.22618 2.61279 2.40299 2.61279ZM8.403 10.6128V11.9461H12.403V10.6128H8.403ZM6.01233 8.61279L4.12699 10.4981L5.06966 11.4415L7.89833 8.61279L5.06966 5.78413L4.12699 6.72746L6.01233 8.61279Z" fill="currentColor"></path></svg> Terminal</div><div><button class="w-full text-start text-primary-dark dark:text-primary-dark "><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.40382 15.3671C5.03332 15.1901 4.70081 14.9381 4.42481 14.6286C4.34831 14.5431 4.23931 14.5001 4.12981 14.5206L3.66181 14.6081C3.33531 14.6691 3.02032 14.4361 2.96232 14.0876L1.30981 4.12512C1.28181 3.95662 1.31731 3.7861 1.40981 3.6456C1.50231 3.5051 1.64082 3.41162 1.79932 3.38162L3.22131 3.00012C3.37681 2.97062 3.48981 2.82761 3.48981 2.65961V1.9101C3.48981 1.8276 3.49381 1.74561 3.49931 1.66461C3.50931 1.53461 3.35181 1.57211 3.35181 1.57211L1.64381 2.0076C1.18481 2.0936 0.751316 2.32662 0.451316 2.70612C0.0808162 3.17362 -0.0686885 3.77259 0.0293115 4.36459L1.68231 14.3281C1.84531 15.3081 2.65031 16.0001 3.55631 16.0001C3.66531 16.0001 3.77631 15.9896 3.88731 15.9691L5.36632 15.6916C5.52332 15.6626 5.54982 15.4366 5.40382 15.3671ZM14.9331 4.55801H12.9116C12.1351 4.55801 11.5001 3.91502 11.5001 3.12952V1.06802C11.5001 0.480524 11.0196 0 10.4321 0H7.44161C6.36911 0 5.50011 0.879508 5.50011 1.96451V12.1665C5.50011 13.179 6.33412 14 7.36262 14H14.1371C15.1661 14 16.0001 13.179 16.0001 12.1665V5.625C16.0001 5.038 15.5201 4.55801 14.9331 4.55801Z" fill="currentColor"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5888 0.0914385C12.4493 0.00843847 12.5158 0.252449 12.5158 0.252449C12.5653 0.428449 12.5918 0.613451 12.5918 0.804451V2.90296C12.5918 3.17646 12.8158 3.40046 13.0903 3.40046H15.1718C15.3883 3.40046 15.5968 3.43495 15.7918 3.49845C15.7918 3.49845 15.9373 3.50844 15.9008 3.43494C15.8383 3.33744 15.7673 3.24494 15.6833 3.16044L12.8303 0.289467C12.7558 0.214467 12.6743 0.149438 12.5888 0.0914385Z" fill="currentColor"></path></svg> <!-- -->Copy</button></div></div></div><div class="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-auto" translate="no" dir="ltr">npm install -D eslint-plugin-react-compiler@beta</div></div> <p class="whitespace-pre-wrap my-4">Then, add it to your ESLint config:</p> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-keyword">import</span> <span class="sp-syntax-plain">reactCompiler</span> <span class="sp-syntax-keyword">from</span> <span class="sp-syntax-string">'eslint-plugin-react-compiler'</span><br/></div><div class="cm-line "><br/></div><div class="cm-line "><span class="sp-syntax-keyword">export</span> <span class="sp-syntax-keyword">default</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-string">'react-compiler'</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-plain">reactCompiler</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">rules</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-string">'react-compiler/react-compiler'</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-string">'error'</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">]</span></div></code></pre></div></div></div></div><!--/$--> <p class="whitespace-pre-wrap my-4">Or, in the deprecated eslintrc config format:</p> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-plain">module</span>.<span class="sp-syntax-property">exports</span> = <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line "> <span class="sp-syntax-string">'eslint-plugin-react-compiler'</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">rules</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-string">'react-compiler/react-compiler'</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-string">'error'</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span></div></code></pre></div></div></div></div><!--/$--> <p class="whitespace-pre-wrap my-4">The ESLint plugin will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase.</p> <div class="expandable-callout pt-8 pb-4 px-5 sm:px-8 my-8 relative rounded-none shadow-inner-border -mx-5 sm:mx-auto sm:rounded-2xl bg-green-5 dark:bg-green-60 dark:bg-opacity-20 text-primary dark:text-primary-dark text-lg"><h3 class="text-2xl font-display font-bold text-green-60 dark:text-green-40"><svg class="inline me-2 mb-1 text-lg text-green-60 dark:text-green-40" width="2em" height="2em" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_40_48064)"><path d="M24 27C24 25.3431 25.3431 24 27 24H45C46.6569 24 48 25.3431 48 27C48 28.6569 46.6569 30 45 30H27C25.3431 30 24 28.6569 24 27Z" fill="currentColor"></path><path d="M24 39C24 37.3431 25.3431 36 27 36H39C40.6569 36 42 37.3431 42 39C42 40.6569 40.6569 42 39 42H27C25.3431 42 24 40.6569 24 39Z" fill="currentColor"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M12 18C12 13.0294 16.0294 9 21 9H51C55.9706 9 60 13.0294 60 18V54C60 58.9706 55.9706 63 51 63H21C16.0294 63 12 58.9706 12 54V18ZM21 15H51C52.6569 15 54 16.3431 54 18V54C54 55.6569 52.6569 57 51 57H21C19.3431 57 18 55.6569 18 54V18C18 16.3431 19.3431 15 21 15Z" fill="currentColor"></path></g><defs><clipPath id="clip0_40_48064"><rect width="72" height="72" fill="white"></rect></clipPath></defs></svg>Note</h3><div class="relative"><div class="py-2"><p class="whitespace-pre-wrap my-4"><strong class="font-bold">You don’t have to fix all ESLint violations straight away.</strong> You can address them at your own pace to increase the amount of components and hooks being optimized, but it is not required to fix everything before you can use the compiler.</p></div></div></div> <h3 id="using-the-compiler-effectively" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Rolling out the compiler to your codebase <a href="#using-the-compiler-effectively" aria-label="Link for Rolling out the compiler to your codebase " title="Link for Rolling out the compiler to your codebase " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <h4 id="existing-projects" class="mdx-heading text-xl font-display font-bold leading-9 my-4">Existing projects <a href="#existing-projects" aria-label="Link for Existing projects " title="Link for Existing projects " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h4> <p class="whitespace-pre-wrap my-4">The compiler is designed to compile functional components and hooks that follow the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="/reference/rules">Rules of React</a>. It can also handle code that breaks those rules by bailing out (skipping over) those components or hooks. However, due to the flexible nature of JavaScript, the compiler cannot catch every possible violation and may compile with false negatives: that is, the compiler may accidentally compile a component/hook that breaks the Rules of React which can lead to undefined behavior.</p> <p class="whitespace-pre-wrap my-4">For this reason, to adopt the compiler successfully on existing projects, we recommend running it on a small directory in your product code first. You can do this by configuring the compiler to only run on a specific set of directories:</p> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-keyword">const</span> <span class="sp-syntax-plain">ReactCompilerConfig</span> = <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">sources</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">(</span><span class="sp-syntax-plain">filename</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">=></span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line bg-github-highlight dark:bg-opacity-10"> <span class="sp-syntax-keyword">return</span> <span class="sp-syntax-plain">filename</span>.<span class="sp-syntax-property">indexOf</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-string">'src/path/to/dir'</span><span class="sp-syntax-punctuation">)</span> !== -<span class="sp-syntax-static">1</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span></div></code></pre></div></div></div></div><!--/$--> <p class="whitespace-pre-wrap my-4">When you have more confidence with rolling out the compiler, you can expand coverage to other directories as well and slowly roll it out to your whole app.</p> <h4 id="new-projects" class="mdx-heading text-xl font-display font-bold leading-9 my-4">New projects <a href="#new-projects" aria-label="Link for New projects " title="Link for New projects " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h4> <p class="whitespace-pre-wrap my-4">If you’re starting a new project, you can enable the compiler on your entire codebase, which is the default behavior.</p> <h3 id="using-react-compiler-with-react-17-or-18" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Using React Compiler with React 17 or 18 <a href="#using-react-compiler-with-react-17-or-18" aria-label="Link for Using React Compiler with React 17 or 18 " title="Link for Using React Compiler with React 17 or 18 " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">React Compiler works best with React 19 RC. If you are unable to upgrade, you can install the extra <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">react-compiler-runtime</code> package which will allow the compiled code to run on versions prior to 19. However, note that the minimum supported version is 17.</p> <div class="rounded-lg bg-secondary dark:bg-gray-50 h-full"><div class="bg-gray-90 dark:bg-gray-60 w-full rounded-t-lg"><div class="text-primary-dark dark:text-primary-dark flex text-sm px-4 py-0.5 relative justify-between"><div><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.40299 2.61279H14.403C14.5798 2.61279 14.7494 2.68303 14.8744 2.80806C14.9994 2.93308 15.0697 3.10265 15.0697 3.27946V13.9461C15.0697 14.1229 14.9994 14.2925 14.8744 14.4175C14.7494 14.5426 14.5798 14.6128 14.403 14.6128H2.40299C2.22618 14.6128 2.05661 14.5426 1.93159 14.4175C1.80657 14.2925 1.73633 14.1229 1.73633 13.9461V3.27946C1.73633 3.10265 1.80657 2.93308 1.93159 2.80806C2.05661 2.68303 2.22618 2.61279 2.40299 2.61279ZM8.403 10.6128V11.9461H12.403V10.6128H8.403ZM6.01233 8.61279L4.12699 10.4981L5.06966 11.4415L7.89833 8.61279L5.06966 5.78413L4.12699 6.72746L6.01233 8.61279Z" fill="currentColor"></path></svg> Terminal</div><div><button class="w-full text-start text-primary-dark dark:text-primary-dark "><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.40382 15.3671C5.03332 15.1901 4.70081 14.9381 4.42481 14.6286C4.34831 14.5431 4.23931 14.5001 4.12981 14.5206L3.66181 14.6081C3.33531 14.6691 3.02032 14.4361 2.96232 14.0876L1.30981 4.12512C1.28181 3.95662 1.31731 3.7861 1.40981 3.6456C1.50231 3.5051 1.64082 3.41162 1.79932 3.38162L3.22131 3.00012C3.37681 2.97062 3.48981 2.82761 3.48981 2.65961V1.9101C3.48981 1.8276 3.49381 1.74561 3.49931 1.66461C3.50931 1.53461 3.35181 1.57211 3.35181 1.57211L1.64381 2.0076C1.18481 2.0936 0.751316 2.32662 0.451316 2.70612C0.0808162 3.17362 -0.0686885 3.77259 0.0293115 4.36459L1.68231 14.3281C1.84531 15.3081 2.65031 16.0001 3.55631 16.0001C3.66531 16.0001 3.77631 15.9896 3.88731 15.9691L5.36632 15.6916C5.52332 15.6626 5.54982 15.4366 5.40382 15.3671ZM14.9331 4.55801H12.9116C12.1351 4.55801 11.5001 3.91502 11.5001 3.12952V1.06802C11.5001 0.480524 11.0196 0 10.4321 0H7.44161C6.36911 0 5.50011 0.879508 5.50011 1.96451V12.1665C5.50011 13.179 6.33412 14 7.36262 14H14.1371C15.1661 14 16.0001 13.179 16.0001 12.1665V5.625C16.0001 5.038 15.5201 4.55801 14.9331 4.55801Z" fill="currentColor"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5888 0.0914385C12.4493 0.00843847 12.5158 0.252449 12.5158 0.252449C12.5653 0.428449 12.5918 0.613451 12.5918 0.804451V2.90296C12.5918 3.17646 12.8158 3.40046 13.0903 3.40046H15.1718C15.3883 3.40046 15.5968 3.43495 15.7918 3.49845C15.7918 3.49845 15.9373 3.50844 15.9008 3.43494C15.8383 3.33744 15.7673 3.24494 15.6833 3.16044L12.8303 0.289467C12.7558 0.214467 12.6743 0.149438 12.5888 0.0914385Z" fill="currentColor"></path></svg> <!-- -->Copy</button></div></div></div><div class="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-auto" translate="no" dir="ltr">npm install react-compiler-runtime@beta</div></div> <p class="whitespace-pre-wrap my-4">You should also add the correct <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">target</code> to your compiler config, where <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">target</code> is the major version of React you are targeting:</p> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-comment">// babel.config.js</span><br/></div><div class="cm-line "><span class="sp-syntax-keyword">const</span> <span class="sp-syntax-plain">ReactCompilerConfig</span> = <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line bg-github-highlight dark:bg-opacity-10"> <span class="sp-syntax-property">target</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-string">'18'</span> <span class="sp-syntax-comment">// '17' | '18' | '19'</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><br/></div><div class="cm-line "><span class="sp-syntax-plain">module</span>.<span class="sp-syntax-property">exports</span> = <span class="sp-syntax-keyword">function</span> <span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">return</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">[</span><span class="sp-syntax-string">'babel-plugin-react-compiler'</span><span class="sp-syntax-punctuation">,</span> <span class="sp-syntax-plain">ReactCompilerConfig</span><span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span></div></code></pre></div></div></div></div><!--/$--> <h3 id="using-the-compiler-on-libraries" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Using the compiler on libraries <a href="#using-the-compiler-on-libraries" aria-label="Link for Using the compiler on libraries " title="Link for Using the compiler on libraries " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">React Compiler can also be used to compile libraries. Because React Compiler needs to run on the original source code prior to any code transformations, it is not possible for an application’s build pipeline to compile the libraries they use. Hence, our recommendation is for library maintainers to independently compile and test their libraries with the compiler, and ship compiled code to npm.</p> <p class="whitespace-pre-wrap my-4">Because your code is pre-compiled, users of your library will not need to have the compiler enabled in order to benefit from the automatic memoization applied to your library. If your library targets apps not yet on React 19, specify a minimum <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="#using-react-compiler-with-react-17-or-18"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">target</code> and add <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">react-compiler-runtime</code> as a direct dependency</a>. The runtime package will use the correct implementation of APIs depending on the application’s version, and polyfill the missing APIs if necessary.</p> <p class="whitespace-pre-wrap my-4">Library code can often require more complex patterns and usage of escape hatches. For this reason, we recommend ensuring that you have sufficient testing in order to identify any issues that might arise from using the compiler on your library. If you identify any issues, you can always opt-out the specific components or hooks with the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="#something-is-not-working-after-compilation"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">'use no memo'</code> directive</a>.</p> <p class="whitespace-pre-wrap my-4">Similarly to apps, it is not necessary to fully compile 100% of your components or hooks to see benefits in your library. A good starting point might be to identify the most performance sensitive parts of your library and ensuring that they don’t break the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="/reference/rules">Rules of React</a>, which you can use <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">eslint-plugin-react-compiler</code> to identify.</p> <h2 id="installation" class="mdx-heading text-3xl font-display leading-10 text-primary dark:text-primary-dark font-bold my-6">Usage <a href="#installation" aria-label="Link for Usage " title="Link for Usage " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h2> <h3 id="usage-with-babel" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Babel <a href="#usage-with-babel" aria-label="Link for Babel " title="Link for Babel " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <div class="rounded-lg bg-secondary dark:bg-gray-50 h-full"><div class="bg-gray-90 dark:bg-gray-60 w-full rounded-t-lg"><div class="text-primary-dark dark:text-primary-dark flex text-sm px-4 py-0.5 relative justify-between"><div><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.40299 2.61279H14.403C14.5798 2.61279 14.7494 2.68303 14.8744 2.80806C14.9994 2.93308 15.0697 3.10265 15.0697 3.27946V13.9461C15.0697 14.1229 14.9994 14.2925 14.8744 14.4175C14.7494 14.5426 14.5798 14.6128 14.403 14.6128H2.40299C2.22618 14.6128 2.05661 14.5426 1.93159 14.4175C1.80657 14.2925 1.73633 14.1229 1.73633 13.9461V3.27946C1.73633 3.10265 1.80657 2.93308 1.93159 2.80806C2.05661 2.68303 2.22618 2.61279 2.40299 2.61279ZM8.403 10.6128V11.9461H12.403V10.6128H8.403ZM6.01233 8.61279L4.12699 10.4981L5.06966 11.4415L7.89833 8.61279L5.06966 5.78413L4.12699 6.72746L6.01233 8.61279Z" fill="currentColor"></path></svg> Terminal</div><div><button class="w-full text-start text-primary-dark dark:text-primary-dark "><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.40382 15.3671C5.03332 15.1901 4.70081 14.9381 4.42481 14.6286C4.34831 14.5431 4.23931 14.5001 4.12981 14.5206L3.66181 14.6081C3.33531 14.6691 3.02032 14.4361 2.96232 14.0876L1.30981 4.12512C1.28181 3.95662 1.31731 3.7861 1.40981 3.6456C1.50231 3.5051 1.64082 3.41162 1.79932 3.38162L3.22131 3.00012C3.37681 2.97062 3.48981 2.82761 3.48981 2.65961V1.9101C3.48981 1.8276 3.49381 1.74561 3.49931 1.66461C3.50931 1.53461 3.35181 1.57211 3.35181 1.57211L1.64381 2.0076C1.18481 2.0936 0.751316 2.32662 0.451316 2.70612C0.0808162 3.17362 -0.0686885 3.77259 0.0293115 4.36459L1.68231 14.3281C1.84531 15.3081 2.65031 16.0001 3.55631 16.0001C3.66531 16.0001 3.77631 15.9896 3.88731 15.9691L5.36632 15.6916C5.52332 15.6626 5.54982 15.4366 5.40382 15.3671ZM14.9331 4.55801H12.9116C12.1351 4.55801 11.5001 3.91502 11.5001 3.12952V1.06802C11.5001 0.480524 11.0196 0 10.4321 0H7.44161C6.36911 0 5.50011 0.879508 5.50011 1.96451V12.1665C5.50011 13.179 6.33412 14 7.36262 14H14.1371C15.1661 14 16.0001 13.179 16.0001 12.1665V5.625C16.0001 5.038 15.5201 4.55801 14.9331 4.55801Z" fill="currentColor"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5888 0.0914385C12.4493 0.00843847 12.5158 0.252449 12.5158 0.252449C12.5653 0.428449 12.5918 0.613451 12.5918 0.804451V2.90296C12.5918 3.17646 12.8158 3.40046 13.0903 3.40046H15.1718C15.3883 3.40046 15.5968 3.43495 15.7918 3.49845C15.7918 3.49845 15.9373 3.50844 15.9008 3.43494C15.8383 3.33744 15.7673 3.24494 15.6833 3.16044L12.8303 0.289467C12.7558 0.214467 12.6743 0.149438 12.5888 0.0914385Z" fill="currentColor"></path></svg> <!-- -->Copy</button></div></div></div><div class="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-auto" translate="no" dir="ltr">npm install babel-plugin-react-compiler@beta</div></div> <p class="whitespace-pre-wrap my-4">The compiler includes a Babel plugin which you can use in your build pipeline to run the compiler.</p> <p class="whitespace-pre-wrap my-4">After installing, add it to your Babel config. Please note that it’s critical that the compiler run <strong class="font-bold">first</strong> in the pipeline:</p> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-comment">// babel.config.js</span><br/></div><div class="cm-line "><span class="sp-syntax-keyword">const</span> <span class="sp-syntax-plain">ReactCompilerConfig</span> = <span class="sp-syntax-punctuation">{</span> <span class="sp-syntax-comment">/* ... */</span> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><br/></div><div class="cm-line "><span class="sp-syntax-plain">module</span>.<span class="sp-syntax-property">exports</span> = <span class="sp-syntax-keyword">function</span> <span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">return</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line bg-github-highlight dark:bg-opacity-10"> <span class="sp-syntax-punctuation">[</span><span class="sp-syntax-string">'babel-plugin-react-compiler'</span><span class="sp-syntax-punctuation">,</span> <span class="sp-syntax-plain">ReactCompilerConfig</span><span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span> <span class="sp-syntax-comment">// must run first!</span><br/></div><div class="cm-line "> <span class="sp-syntax-comment">// ...</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span></div></code></pre></div></div></div></div><!--/$--> <p class="whitespace-pre-wrap my-4"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">babel-plugin-react-compiler</code> should run first before other Babel plugins as the compiler requires the input source information for sound analysis.</p> <h3 id="usage-with-vite" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Vite <a href="#usage-with-vite" aria-label="Link for Vite " title="Link for Vite " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">If you use Vite, you can add the plugin to vite-plugin-react:</p> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-comment">// vite.config.js</span><br/></div><div class="cm-line "><span class="sp-syntax-keyword">const</span> <span class="sp-syntax-plain">ReactCompilerConfig</span> = <span class="sp-syntax-punctuation">{</span> <span class="sp-syntax-comment">/* ... */</span> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><br/></div><div class="cm-line "><span class="sp-syntax-keyword">export</span> <span class="sp-syntax-keyword">default</span> <span class="sp-syntax-definition">defineConfig</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">=></span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-keyword">return</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line "> <span class="sp-syntax-definition">react</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">babel</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line bg-github-highlight dark:bg-opacity-10"> <span class="sp-syntax-punctuation">[</span><span class="sp-syntax-string">"babel-plugin-react-compiler"</span><span class="sp-syntax-punctuation">,</span> <span class="sp-syntax-plain">ReactCompilerConfig</span><span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-comment">// ...</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">;</span></div></code></pre></div></div></div></div><!--/$--> <h3 id="usage-with-nextjs" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Next.js <a href="#usage-with-nextjs" aria-label="Link for Next.js " title="Link for Next.js " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">Please refer to the <a href="https://nextjs.org/docs/app/api-reference/next-config-js/reactCompiler" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">Next.js docs</a> for more information.</p> <h3 id="usage-with-remix" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Remix <a href="#usage-with-remix" aria-label="Link for Remix " title="Link for Remix " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">Install <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">vite-plugin-babel</code>, and add the compiler’s Babel plugin to it:</p> <div class="rounded-lg bg-secondary dark:bg-gray-50 h-full"><div class="bg-gray-90 dark:bg-gray-60 w-full rounded-t-lg"><div class="text-primary-dark dark:text-primary-dark flex text-sm px-4 py-0.5 relative justify-between"><div><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.40299 2.61279H14.403C14.5798 2.61279 14.7494 2.68303 14.8744 2.80806C14.9994 2.93308 15.0697 3.10265 15.0697 3.27946V13.9461C15.0697 14.1229 14.9994 14.2925 14.8744 14.4175C14.7494 14.5426 14.5798 14.6128 14.403 14.6128H2.40299C2.22618 14.6128 2.05661 14.5426 1.93159 14.4175C1.80657 14.2925 1.73633 14.1229 1.73633 13.9461V3.27946C1.73633 3.10265 1.80657 2.93308 1.93159 2.80806C2.05661 2.68303 2.22618 2.61279 2.40299 2.61279ZM8.403 10.6128V11.9461H12.403V10.6128H8.403ZM6.01233 8.61279L4.12699 10.4981L5.06966 11.4415L7.89833 8.61279L5.06966 5.78413L4.12699 6.72746L6.01233 8.61279Z" fill="currentColor"></path></svg> Terminal</div><div><button class="w-full text-start text-primary-dark dark:text-primary-dark "><svg class="inline-flex me-2 self-center" width="1em" height="1em" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.40382 15.3671C5.03332 15.1901 4.70081 14.9381 4.42481 14.6286C4.34831 14.5431 4.23931 14.5001 4.12981 14.5206L3.66181 14.6081C3.33531 14.6691 3.02032 14.4361 2.96232 14.0876L1.30981 4.12512C1.28181 3.95662 1.31731 3.7861 1.40981 3.6456C1.50231 3.5051 1.64082 3.41162 1.79932 3.38162L3.22131 3.00012C3.37681 2.97062 3.48981 2.82761 3.48981 2.65961V1.9101C3.48981 1.8276 3.49381 1.74561 3.49931 1.66461C3.50931 1.53461 3.35181 1.57211 3.35181 1.57211L1.64381 2.0076C1.18481 2.0936 0.751316 2.32662 0.451316 2.70612C0.0808162 3.17362 -0.0686885 3.77259 0.0293115 4.36459L1.68231 14.3281C1.84531 15.3081 2.65031 16.0001 3.55631 16.0001C3.66531 16.0001 3.77631 15.9896 3.88731 15.9691L5.36632 15.6916C5.52332 15.6626 5.54982 15.4366 5.40382 15.3671ZM14.9331 4.55801H12.9116C12.1351 4.55801 11.5001 3.91502 11.5001 3.12952V1.06802C11.5001 0.480524 11.0196 0 10.4321 0H7.44161C6.36911 0 5.50011 0.879508 5.50011 1.96451V12.1665C5.50011 13.179 6.33412 14 7.36262 14H14.1371C15.1661 14 16.0001 13.179 16.0001 12.1665V5.625C16.0001 5.038 15.5201 4.55801 14.9331 4.55801Z" fill="currentColor"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5888 0.0914385C12.4493 0.00843847 12.5158 0.252449 12.5158 0.252449C12.5653 0.428449 12.5918 0.613451 12.5918 0.804451V2.90296C12.5918 3.17646 12.8158 3.40046 13.0903 3.40046H15.1718C15.3883 3.40046 15.5968 3.43495 15.7918 3.49845C15.7918 3.49845 15.9373 3.50844 15.9008 3.43494C15.8383 3.33744 15.7673 3.24494 15.6833 3.16044L12.8303 0.289467C12.7558 0.214467 12.6743 0.149438 12.5888 0.0914385Z" fill="currentColor"></path></svg> <!-- -->Copy</button></div></div></div><div class="px-8 pt-4 pb-6 text-primary-dark dark:text-primary-dark font-mono text-code whitespace-pre overflow-x-auto" translate="no" dir="ltr">npm install vite-plugin-babel</div></div> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-comment">// vite.config.js</span><br/></div><div class="cm-line bg-github-highlight dark:bg-opacity-10"><span class="sp-syntax-keyword">import</span> <span class="sp-syntax-plain">babel</span> <span class="sp-syntax-keyword">from</span> <span class="sp-syntax-string">"vite-plugin-babel"</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><br/></div><div class="cm-line "><span class="sp-syntax-keyword">const</span> <span class="sp-syntax-plain">ReactCompilerConfig</span> = <span class="sp-syntax-punctuation">{</span> <span class="sp-syntax-comment">/* ... */</span> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">;</span><br/></div><div class="cm-line "><br/></div><div class="cm-line "><span class="sp-syntax-keyword">export</span> <span class="sp-syntax-keyword">default</span> <span class="sp-syntax-definition">defineConfig</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line "> <span class="sp-syntax-definition">remix</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">{</span> <span class="sp-syntax-comment">/* ... */</span><span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-definition">babel</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">filter</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-string">/\.[jt]sx?$/</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">babelConfig</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">presets</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><span class="sp-syntax-string">"@babel/preset-typescript"</span><span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span> <span class="sp-syntax-comment">// if you use TypeScript</span><br/></div><div class="cm-line "> <span class="sp-syntax-property">plugins</span><span class="sp-syntax-punctuation">:</span> <span class="sp-syntax-punctuation">[</span><br/></div><div class="cm-line bg-github-highlight dark:bg-opacity-10"> <span class="sp-syntax-punctuation">[</span><span class="sp-syntax-string">"babel-plugin-react-compiler"</span><span class="sp-syntax-punctuation">,</span> <span class="sp-syntax-plain">ReactCompilerConfig</span><span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "> <span class="sp-syntax-punctuation">]</span><span class="sp-syntax-punctuation">,</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span><span class="sp-syntax-punctuation">)</span><span class="sp-syntax-punctuation">;</span></div></code></pre></div></div></div></div><!--/$--> <h3 id="usage-with-webpack" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Webpack <a href="#usage-with-webpack" aria-label="Link for Webpack " title="Link for Webpack " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">A community webpack loader is <a href="https://github.com/SukkaW/react-compiler-webpack" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">now available here</a>.</p> <h3 id="usage-with-expo" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Expo <a href="#usage-with-expo" aria-label="Link for Expo " title="Link for Expo " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">Please refer to <a href="https://docs.expo.dev/guides/react-compiler/" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">Expo’s docs</a> to enable and use the React Compiler in Expo apps.</p> <h3 id="usage-with-react-native-metro" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Metro (React Native) <a href="#usage-with-react-native-metro" aria-label="Link for Metro (React Native) " title="Link for Metro (React Native) " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">React Native uses Babel via Metro, so refer to the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="#usage-with-babel">Usage with Babel</a> section for installation instructions.</p> <h3 id="usage-with-rspack" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Rspack <a href="#usage-with-rspack" aria-label="Link for Rspack " title="Link for Rspack " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">Please refer to <a href="https://rspack.dev/guide/tech/react#react-compiler" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">Rspack’s docs</a> to enable and use the React Compiler in Rspack apps.</p> <h3 id="usage-with-rsbuild" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Rsbuild <a href="#usage-with-rsbuild" aria-label="Link for Rsbuild " title="Link for Rsbuild " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">Please refer to <a href="https://rsbuild.dev/guide/framework/react#react-compiler" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">Rsbuild’s docs</a> to enable and use the React Compiler in Rsbuild apps.</p> <h2 id="troubleshooting" class="mdx-heading text-3xl font-display leading-10 text-primary dark:text-primary-dark font-bold my-6">Troubleshooting <a href="#troubleshooting" aria-label="Link for Troubleshooting " title="Link for Troubleshooting " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h2> <p class="whitespace-pre-wrap my-4">To report issues, please first create a minimal repro on the <a href="https://playground.react.dev/" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">React Compiler Playground</a> and include it in your bug report. You can open issues in the <a href="https://github.com/facebook/react/issues" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">facebook/react</a> repo.</p> <p class="whitespace-pre-wrap my-4">You can also provide feedback in the React Compiler Working Group by applying to be a member. Please see <a href="https://github.com/reactwg/react-compiler" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">the README for more details on joining</a>.</p> <h3 id="what-does-the-compiler-assume" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">What does the compiler assume? <a href="#what-does-the-compiler-assume" aria-label="Link for What does the compiler assume? " title="Link for What does the compiler assume? " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">React Compiler assumes that your code:</p> <ol class="ms-6 my-3 list-decimal"> <li class="leading-relaxed mb-1">Is valid, semantic JavaScript.</li> <li class="leading-relaxed mb-1">Tests that nullable/optional values and properties are defined before accessing them (for example, by enabling <a href="https://www.typescriptlang.org/tsconfig/#strictNullChecks" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">strictNullChecks</code></a> if using TypeScript), i.e., <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">if (object.nullableProperty) { object.nullableProperty.foo }</code> or with optional-chaining <code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">object.nullableProperty?.foo</code>.</li> <li class="leading-relaxed mb-1">Follows the <a href="https://react.dev/reference/rules" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">Rules of React</a>.</li> </ol> <p class="whitespace-pre-wrap my-4">React Compiler can verify many of the Rules of React statically, and will safely skip compilation when it detects an error. To see the errors we recommend also installing <a href="https://www.npmjs.com/package/eslint-plugin-react-compiler" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">eslint-plugin-react-compiler</a>.</p> <h3 id="how-do-i-know-my-components-have-been-optimized" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">How do I know my components have been optimized? <a href="#how-do-i-know-my-components-have-been-optimized" aria-label="Link for How do I know my components have been optimized? " title="Link for How do I know my components have been optimized? " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4"><a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="/learn/react-developer-tools">React DevTools</a> (v5.0+) and <a href="https://reactnative.dev/docs/react-native-devtools" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">React Native DevTools</a> have built-in support for React Compiler and will display a “Memo ✨” badge next to components that have been optimized by the compiler.</p> <h3 id="something-is-not-working-after-compilation" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Something is not working after compilation <a href="#something-is-not-working-after-compilation" aria-label="Link for Something is not working after compilation " title="Link for Something is not working after compilation " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">If you have eslint-plugin-react-compiler installed, the compiler will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase. <strong class="font-bold">You don’t have to fix all ESLint violations straight away.</strong> You can address them at your own pace to increase the amount of components and hooks being optimized.</p> <p class="whitespace-pre-wrap my-4">Due to the flexible and dynamic nature of JavaScript however, it’s not possible to comprehensively detect all cases. Bugs and undefined behavior such as infinite loops may occur in those cases.</p> <p class="whitespace-pre-wrap my-4">If your app doesn’t work properly after compilation and you aren’t seeing any ESLint errors, the compiler may be incorrectly compiling your code. To confirm this, try to make the issue go away by aggressively opting out any component or hook you think might be related via the <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="#opt-out-of-the-compiler-for-a-component"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">"use no memo"</code> directive</a>.</p> <!--$--><div dir="ltr" class="sandpack sandpack--codeblock rounded-2xl h-full w-full overflow-x-auto flex items-center bg-wash dark:bg-gray-95 shadow-lg my-8" style="contain:content"><div class="sp-wrapper"><div class="sp-stack"><div class="sp-code-editor"><pre class="sp-cm sp-pristine sp-javascript flex align-start"><code class="sp-pre-placeholder grow-[2]"><div class="cm-line "><span class="sp-syntax-keyword">function</span> <span class="sp-syntax-definition">SuspiciousComponent</span><span class="sp-syntax-punctuation">(</span><span class="sp-syntax-punctuation">)</span> <span class="sp-syntax-punctuation">{</span><br/></div><div class="cm-line bg-github-highlight dark:bg-opacity-10"> <span class="sp-syntax-string">"use no memo"</span><span class="sp-syntax-punctuation">;</span> <span class="sp-syntax-comment">// opts out this component from being compiled by React Compiler</span><br/></div><div class="cm-line "> <span class="sp-syntax-comment">// ...</span><br/></div><div class="cm-line "><span class="sp-syntax-punctuation">}</span></div></code></pre></div></div></div></div><!--/$--> <div class="expandable-callout pt-8 pb-4 px-5 sm:px-8 my-8 relative rounded-none shadow-inner-border -mx-5 sm:mx-auto sm:rounded-2xl bg-green-5 dark:bg-green-60 dark:bg-opacity-20 text-primary dark:text-primary-dark text-lg"><h3 class="text-2xl font-display font-bold text-green-60 dark:text-green-40"><svg class="inline me-2 mb-1 text-lg text-green-60 dark:text-green-40" width="2em" height="2em" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_40_48064)"><path d="M24 27C24 25.3431 25.3431 24 27 24H45C46.6569 24 48 25.3431 48 27C48 28.6569 46.6569 30 45 30H27C25.3431 30 24 28.6569 24 27Z" fill="currentColor"></path><path d="M24 39C24 37.3431 25.3431 36 27 36H39C40.6569 36 42 37.3431 42 39C42 40.6569 40.6569 42 39 42H27C25.3431 42 24 40.6569 24 39Z" fill="currentColor"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M12 18C12 13.0294 16.0294 9 21 9H51C55.9706 9 60 13.0294 60 18V54C60 58.9706 55.9706 63 51 63H21C16.0294 63 12 58.9706 12 54V18ZM21 15H51C52.6569 15 54 16.3431 54 18V54C54 55.6569 52.6569 57 51 57H21C19.3431 57 18 55.6569 18 54V18C18 16.3431 19.3431 15 21 15Z" fill="currentColor"></path></g><defs><clipPath id="clip0_40_48064"><rect width="72" height="72" fill="white"></rect></clipPath></defs></svg>Note</h3><div class="relative"><div class="py-2"><h4 id="use-no-memo" class="mdx-heading text-xl font-display font-bold leading-9 my-4"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">"use no memo"</code> <a href="#use-no-memo" aria-label="Link for this heading" title="Link for this heading" class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h4><p class="whitespace-pre-wrap my-4"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">"use no memo"</code> is a <em>temporary</em> escape hatch that lets you opt-out components and hooks from being compiled by the React Compiler. This directive is not meant to be long lived the same way as eg <a class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal" href="/reference/rsc/use-client"><code dir="ltr" class="inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline bg-gray-30 bg-opacity-10 py-px">"use client"</code></a> is.</p><p class="whitespace-pre-wrap my-4">It is not recommended to reach for this directive unless it’s strictly necessary. Once you opt-out a component or hook, it is opted-out forever until the directive is removed. This means that even if you fix the code, the compiler will still skip over compiling it unless you remove the directive.</p></div></div></div> <p class="whitespace-pre-wrap my-4">When you make the error go away, confirm that removing the opt out directive makes the issue come back. Then share a bug report with us (you can try to reduce it to a small repro, or if it’s open source code you can also just paste the entire source) using the <a href="https://playground.react.dev" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">React Compiler Playground</a> so we can identify and help fix the issue.</p> <h3 id="other-issues" class="mdx-heading text-2xl font-display leading-9 text-primary dark:text-primary-dark font-bold my-6">Other issues <a href="#other-issues" aria-label="Link for Other issues " title="Link for Other issues " class="mdx-header-anchor inline-block"><svg width="1em" height="1em" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg" class="text-gray-70 ms-2 h-5 w-5"><g fill="currentColor" fill-rule="evenodd"><path d="M7.778 7.975a2.5 2.5 0 0 0 .347-3.837L6.017 2.03a2.498 2.498 0 0 0-3.542-.007 2.5 2.5 0 0 0 .006 3.543l1.153 1.15c.07-.29.154-.563.25-.773.036-.077.084-.16.14-.25L3.18 4.85a1.496 1.496 0 0 1 .002-2.12 1.496 1.496 0 0 1 2.12 0l2.124 2.123a1.496 1.496 0 0 1-.333 2.37c.16.246.42.504.685.752z"></path><path d="M5.657 4.557a2.5 2.5 0 0 0-.347 3.837l2.108 2.108a2.498 2.498 0 0 0 3.542.007 2.5 2.5 0 0 0-.006-3.543L9.802 5.815c-.07.29-.154.565-.25.774-.036.076-.084.16-.14.25l.842.84c.585.587.59 1.532 0 2.122-.587.585-1.532.59-2.12 0L6.008 7.68a1.496 1.496 0 0 1 .332-2.372c-.16-.245-.42-.503-.685-.75z"></path></g></svg></a></h3> <p class="whitespace-pre-wrap my-4">Please see <a href="https://github.com/reactwg/react-compiler/discussions/7" target="_blank" rel="nofollow noopener noreferrer" class="inline text-link dark:text-link-dark border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal">https://github.com/reactwg/react-compiler/discussions/7</a>.</p></div></div><div class="grid grid-cols-1 gap-4 py-4 mx-auto max-w-7xl md:grid-cols-2 md:py-12"><a class="flex gap-x-4 md:gap-x-6 items-center w-full md:min-w-80 md:w-fit md:max-w-md px-4 md:px-5 py-6 border-2 border-transparent text-base leading-base text-link dark:text-link-dark rounded-lg group focus:text-link dark:focus:text-link-dark focus:bg-highlight focus:border-link dark:focus:bg-highlight-dark dark:focus:border-link-dark focus:border-opacity-100 focus:border-2 focus:ring-1 focus:ring-offset-4 focus:ring-blue-40 active:ring-0 active:ring-offset-0 hover:bg-gray-5 dark:hover:bg-gray-80" href="/learn/react-developer-tools"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="duration-100 ease-in transition rotate-90 rtl:-rotate-90 inline text-tertiary dark:text-tertiary-dark group-focus:text-link dark:group-focus:text-link-dark" style="min-width:20px;min-height:20px"><g fill="none" fill-rule="evenodd" transform="translate(-446 -398)"><path fill="currentColor" fill-rule="nonzero" d="M95.8838835,240.366117 C95.3957281,239.877961 94.6042719,239.877961 94.1161165,240.366117 C93.6279612,240.854272 93.6279612,241.645728 94.1161165,242.133883 L98.6161165,246.633883 C99.1042719,247.122039 99.8957281,247.122039 100.383883,246.633883 L104.883883,242.133883 C105.372039,241.645728 105.372039,240.854272 104.883883,240.366117 C104.395728,239.877961 103.604272,239.877961 103.116117,240.366117 L99.5,243.982233 L95.8838835,240.366117 Z" transform="translate(356.5 164.5)"></path><polygon points="446 418 466 418 466 398 446 398"></polygon></g></svg><div class="flex flex-col overflow-hidden"><span class="text-sm font-bold tracking-wide no-underline uppercase text-secondary dark:text-secondary-dark group-focus:text-link dark:group-focus:text-link-dark group-focus:text-opacity-100">Previous</span><span class="text-lg break-words group-hover:underline">React Developer Tools</span></div></a><div></div></div></div></div></article><div class="self-stretch w-full"><div class="w-full px-5 pt-10 mx-auto sm:px-12 md:px-12 md:pt-12 lg:pt-10"><hr class="mx-auto max-w-7xl border-border dark:border-border-dark"/></div><div class="py-12 px-5 sm:px-12 md:px-12 sm:py-12 md:py-16 lg:py-14"><footer class="text-secondary dark:text-secondary-dark"><div class="grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-x-12 gap-y-8 max-w-7xl mx-auto"><div class="col-span-2 md:col-span-1 justify-items-start mt-3.5"><a href="https://opensource.fb.com/" target="_blank" rel="noopener" aria-label="Meta Open Source"><div><svg width="160" height="19" viewBox="0 0 160 19" fill="none" xmlns="http://www.w3.org/2000/svg" class="text-primary dark:text-primary-dark"><path d="M22.0605 3.62598H24.3349L28.202 10.6212L32.0691 3.62598H34.2942V15.1206H32.4387V6.31077L29.0476 12.4111H27.307L23.9162 6.31077V15.1206H22.0605V3.62598Z" fill="currentColor"></path><path d="M40.2785 15.3259C39.4191 15.3259 38.6638 15.1357 38.0124 14.7554C37.367 14.3812 36.8394 13.8336 36.4895 13.1747C36.1253 12.5015 35.9433 11.7297 35.9434 10.8594C35.9434 9.97825 36.1213 9.19824 36.4771 8.5194C36.8329 7.84077 37.3269 7.30982 37.9592 6.92653C38.5913 6.54347 39.3179 6.3519 40.139 6.35181C40.9546 6.35181 41.6566 6.54477 42.2449 6.9307C42.8334 7.31658 43.2863 7.85713 43.6038 8.55232C43.9212 9.24748 44.08 10.063 44.0801 10.9989V11.5081H37.7826C37.8975 12.2088 38.1808 12.7602 38.6323 13.1625C39.0839 13.5648 39.6546 13.7659 40.3443 13.766C40.8971 13.766 41.3733 13.6839 41.7729 13.5196C42.1723 13.3554 42.5473 13.1063 42.8977 12.7724L43.8831 13.9794C42.9031 14.8771 41.7016 15.326 40.2785 15.3259ZM41.6334 8.50718C41.2447 8.11027 40.7356 7.91184 40.1062 7.91189C39.4931 7.91189 38.9799 8.11439 38.5667 8.51941C38.1533 8.92464 37.8919 9.46931 37.7826 10.1534H42.2984C42.2436 9.45273 42.0219 8.90398 41.6334 8.50716V8.50718Z" fill="currentColor"></path><path d="M46.3308 8.07609H44.623V6.55715H46.3308V4.04468H48.1209V6.55715H50.7153V8.07609H48.1209V11.9267C48.1209 12.5672 48.2303 13.0243 48.4492 13.298C48.6682 13.5717 49.0431 13.7086 49.5741 13.7084C49.7742 13.7102 49.9743 13.7006 50.1734 13.6797C50.3376 13.6606 50.5183 13.6346 50.7153 13.6017V15.1043C50.4905 15.1692 50.2614 15.2186 50.0297 15.252C49.7647 15.2911 49.4971 15.3103 49.2292 15.3095C47.2969 15.3095 46.3308 14.2531 46.3308 12.1403L46.3308 8.07609Z" fill="currentColor"></path><path d="M60.0415 15.1207H58.2844V13.9219C57.9815 14.3629 57.572 14.7202 57.094 14.9606C56.6123 15.204 56.0649 15.3258 55.4519 15.3259C54.6966 15.3259 54.0274 15.133 53.4444 14.7472C52.8614 14.3611 52.4029 13.8302 52.0692 13.1543C51.7353 12.4784 51.5684 11.7052 51.5684 10.8348C51.5684 9.95904 51.738 9.1845 52.0774 8.5112C52.4167 7.83795 52.8861 7.30972 53.4855 6.92653C54.0847 6.54347 54.773 6.3519 55.5503 6.35181C56.1361 6.35181 56.6616 6.46538 57.1269 6.69253C57.5858 6.91465 57.9833 7.24591 58.2844 7.65731V6.55718H60.0415V15.1207ZM58.2516 9.55395C58.06 9.06686 57.7576 8.68232 57.3444 8.40033C56.9311 8.11861 56.4535 7.97771 55.9116 7.97762C55.1452 7.97762 54.5349 8.23487 54.0807 8.74939C53.6264 9.2639 53.3993 9.95905 53.3993 10.8349C53.3993 11.7162 53.6182 12.4141 54.0561 12.9285C54.4939 13.443 55.0877 13.7003 55.8377 13.7003C56.3906 13.7003 56.8833 13.5579 57.3156 13.2733C57.7405 12.9979 58.068 12.5957 58.2516 12.1238V9.55395Z" fill="currentColor"></path><path d="M64.4113 11.7585C64.1266 11.0332 63.9843 10.2382 63.9844 9.3733C63.9844 8.50853 64.1267 7.71351 64.4113 6.98824C64.6823 6.28392 65.0929 5.6416 65.6182 5.09981C66.1399 4.56496 66.7659 4.14298 67.4573 3.86003C68.1634 3.56716 68.9379 3.4207 69.7808 3.42065C70.6238 3.42065 71.3984 3.56711 72.1045 3.86003C72.796 4.14302 73.422 4.56499 73.9437 5.09981C74.4689 5.64171 74.8795 6.284 75.1507 6.98824C75.4351 7.71351 75.5774 8.50853 75.5776 9.3733C75.5776 10.2382 75.4353 11.0333 75.1507 11.7585C74.8795 12.4627 74.4689 13.105 73.9437 13.6469C73.422 14.1818 72.796 14.6038 72.1045 14.8867C71.3984 15.1794 70.6239 15.3259 69.7808 15.3259C68.938 15.3259 68.1635 15.1795 67.4573 14.8867C66.7658 14.6038 66.1399 14.1818 65.6182 13.6469C65.0929 13.1051 64.6823 12.4628 64.4113 11.7585ZM73.6152 9.3733C73.6152 8.54697 73.451 7.81763 73.1226 7.18529C72.7942 6.55303 72.3413 6.05904 71.7637 5.70331C71.1862 5.34753 70.5252 5.16962 69.7808 5.16958C69.0365 5.16958 68.3756 5.34749 67.7981 5.70331C67.2205 6.05909 66.7676 6.55308 66.4392 7.18529C66.1108 7.81741 65.9466 8.54674 65.9466 9.3733C65.9466 10.1999 66.1108 10.9293 66.4392 11.5615C66.7677 12.1937 67.2206 12.6877 67.7981 13.0434C68.3755 13.3993 69.0364 13.5773 69.7808 13.5772C70.5252 13.5772 71.1862 13.3993 71.7637 13.0434C72.3413 12.6877 72.7942 12.1937 73.1226 11.5615C73.451 10.9292 73.6152 10.1998 73.6152 9.3733V9.3733Z" fill="currentColor"></path><path d="M77.2188 6.55718H78.9839V7.74763C79.2856 7.30796 79.6938 6.95201 80.1705 6.71309C80.6492 6.47237 81.1952 6.35194 81.8084 6.35181C82.5637 6.35181 83.2342 6.54477 83.8199 6.9307C84.4056 7.31658 84.8641 7.84615 85.1952 8.5194C85.5263 9.19264 85.6919 9.96719 85.6919 10.843C85.6919 11.7133 85.5223 12.4865 85.1829 13.1625C84.8436 13.8386 84.3742 14.3681 83.7747 14.7512C83.1755 15.1343 82.4873 15.3258 81.71 15.3259C81.1353 15.3259 80.618 15.2165 80.1581 14.9976C79.7045 14.7837 79.31 14.4624 79.0087 14.0616V18.569H77.2188V6.55718ZM79.9159 13.2774C80.3291 13.5594 80.8067 13.7004 81.3487 13.7003C82.1148 13.7003 82.7251 13.443 83.1796 12.9285C83.6339 12.414 83.861 11.7188 83.861 10.843C83.861 9.96172 83.6421 9.26383 83.2042 8.74937C82.7662 8.23486 82.1723 7.9776 81.4226 7.9776C80.8697 7.9776 80.377 8.11989 79.9447 8.40448C79.5197 8.67987 79.1923 9.08202 79.0087 9.55393V12.1238C79.2002 12.611 79.5026 12.9956 79.9159 13.2774Z" fill="currentColor"></path><path d="M91.177 15.3259C90.3176 15.3259 89.5622 15.1357 88.9109 14.7554C88.2654 14.3812 87.7377 13.8336 87.3878 13.1747C87.0236 12.5015 86.8417 11.7297 86.8418 10.8594C86.8418 9.97825 87.0197 9.19824 87.3754 8.5194C87.7312 7.84077 88.2252 7.30982 88.8574 6.92653C89.4896 6.54347 90.2163 6.3519 91.0373 6.35181C91.8528 6.35181 92.5548 6.54477 93.1434 6.9307C93.7317 7.31658 94.1846 7.85713 94.5022 8.55232C94.8196 9.24748 94.9782 10.063 94.9783 10.9989V11.5081H88.6809C88.7958 12.2088 89.0791 12.7602 89.5308 13.1625C89.9824 13.5648 90.553 13.7659 91.2426 13.766C91.7954 13.766 92.2716 13.6839 92.6712 13.5196C93.0708 13.3554 93.4457 13.1063 93.796 12.7724L94.7812 13.9794C93.8014 14.8771 92.6 15.326 91.177 15.3259ZM92.5315 8.50718C92.1428 8.11027 91.6338 7.91184 91.0044 7.91189C90.3914 7.91189 89.8782 8.11439 89.465 8.51941C89.0517 8.92464 88.7903 9.46931 88.6809 10.1534H93.1966C93.1419 9.45273 92.9202 8.90398 92.5315 8.50716V8.50718Z" fill="currentColor"></path><path d="M96.4883 6.55718H98.2536V7.80515C98.9158 6.83621 99.8381 6.35176 101.021 6.35181C102.039 6.35181 102.821 6.66928 103.369 7.30422C103.916 7.93929 104.19 8.84793 104.19 10.0301V15.1207H102.4V10.2436C102.4 9.44454 102.258 8.85615 101.973 8.47842C101.688 8.10074 101.242 7.9119 100.635 7.9119C100.104 7.9119 99.6356 8.04872 99.2307 8.32238C98.8255 8.59617 98.508 8.97932 98.2783 9.47183V15.1207H96.4883L96.4883 6.55718Z" fill="currentColor"></path><path d="M116.875 11.8694C116.875 12.9586 116.499 13.8071 115.746 14.4147C114.994 15.0222 113.914 15.3259 112.507 15.3259C111.451 15.3259 110.511 15.1262 109.687 14.7266C108.863 14.3272 108.221 13.7469 107.762 12.9859L109.157 11.8858C109.54 12.466 110.019 12.8971 110.594 13.1789C111.169 13.4609 111.829 13.6018 112.573 13.6018C113.323 13.6018 113.906 13.4594 114.322 13.1747C114.738 12.8902 114.946 12.5043 114.946 12.0171C114.946 11.5957 114.801 11.2468 114.511 10.9703C114.221 10.694 113.728 10.4846 113.033 10.3422L111.309 9.98094C109.196 9.54304 108.139 8.47567 108.139 6.77883C108.139 6.10558 108.315 5.51714 108.665 5.01352C109.015 4.51002 109.512 4.11867 110.155 3.83947C110.798 3.56031 111.552 3.4207 112.417 3.42065C114.338 3.42065 115.775 4.16509 116.727 5.65397L115.315 6.66391C114.976 6.14939 114.572 5.76759 114.104 5.51849C113.636 5.26943 113.068 5.14492 112.401 5.14497C111.662 5.14497 111.088 5.28041 110.681 5.55128C110.273 5.82225 110.069 6.20952 110.069 6.7131C110.069 7.09629 110.202 7.40557 110.467 7.64091C110.732 7.87626 111.196 8.0651 111.859 8.20744L113.583 8.56874C115.778 9.02855 116.875 10.1288 116.875 11.8694Z" fill="currentColor"></path><path d="M118.677 13.1831C118.308 12.5097 118.123 11.7297 118.123 10.843C118.123 9.95083 118.308 9.16809 118.677 8.4948C119.034 7.83483 119.569 7.28851 120.221 6.91833C120.88 6.54065 121.645 6.3518 122.516 6.35181C123.386 6.35181 124.151 6.54065 124.81 6.91833C125.463 7.28862 125.998 7.83491 126.354 8.4948C126.724 9.16805 126.908 9.95079 126.908 10.843C126.908 11.7297 126.724 12.5097 126.354 13.1831C125.998 13.8429 125.463 14.3892 124.81 14.7594C124.151 15.1371 123.386 15.3259 122.516 15.3259C121.651 15.3259 120.887 15.1371 120.225 14.7594C119.571 14.3902 119.034 13.8438 118.677 13.1831ZM125.077 10.843C125.077 9.98377 124.843 9.29408 124.375 8.77396C123.907 8.25393 123.288 7.99394 122.516 7.994C121.744 7.994 121.124 8.25398 120.656 8.77396C120.188 9.29399 119.954 9.98368 119.954 10.843C119.954 11.6969 120.188 12.3839 120.656 12.9039C121.124 13.4239 121.744 13.6839 122.516 13.6839C123.288 13.6839 123.907 13.4239 124.375 12.9039C124.843 12.3839 125.077 11.6969 125.077 10.843Z" fill="currentColor"></path><path d="M135.907 15.1206H134.141V13.8891C133.484 14.847 132.576 15.3259 131.415 15.3259C130.408 15.3259 129.635 15.0084 129.096 14.3735C128.557 13.7385 128.287 12.8299 128.287 11.6475V6.55713H130.077V11.4341C130.077 12.2278 130.217 12.8148 130.496 13.1953C130.775 13.5758 131.213 13.766 131.809 13.7659C132.324 13.7659 132.781 13.6305 133.18 13.3595C133.58 13.0885 133.892 12.7095 134.116 12.2223V6.55713H135.907L135.907 15.1206Z" fill="currentColor"></path><path d="M137.877 6.55733H139.642V7.8709C140.195 6.91311 140.95 6.43417 141.908 6.43408C142.22 6.43408 142.475 6.46146 142.672 6.5162V8.16659C142.403 8.12858 142.131 8.10936 141.859 8.10907C140.786 8.10907 140.055 8.59074 139.667 9.55408V15.1208H137.877L137.877 6.55733Z" fill="currentColor"></path><path d="M143.737 8.49063C144.079 7.83229 144.601 7.28535 145.244 6.9143C145.889 6.53944 146.645 6.35194 147.51 6.35181C149.119 6.35181 150.318 6.98952 151.106 8.26496L149.71 9.20918C149.431 8.78768 149.119 8.47975 148.774 8.2854C148.429 8.09118 148.013 7.99405 147.526 7.994C146.782 7.994 146.18 8.25534 145.72 8.778C145.26 9.30085 145.03 9.98647 145.03 10.8348C145.03 11.727 145.255 12.4249 145.703 12.9285C146.152 13.4321 146.785 13.6839 147.6 13.6839C148.034 13.6874 148.463 13.5845 148.848 13.3841C149.218 13.1962 149.536 12.9215 149.776 12.5836L151.024 13.6839C150.186 14.7786 149.031 15.326 147.559 15.3259C146.678 15.3259 145.91 15.1412 145.256 14.7718C144.609 14.4099 144.081 13.8679 143.737 13.2117C143.378 12.5413 143.199 11.7544 143.199 10.8512C143.199 9.95352 143.378 9.16666 143.737 8.49063Z" fill="currentColor"></path><path d="M156.195 15.3259C155.335 15.3259 154.58 15.1357 153.928 14.7554C153.283 14.3812 152.755 13.8336 152.405 13.1747C152.041 12.5015 151.859 11.7297 151.859 10.8594C151.859 9.97825 152.037 9.19824 152.393 8.5194C152.749 7.84077 153.243 7.30982 153.875 6.92653C154.507 6.54347 155.234 6.3519 156.055 6.35181C156.87 6.35181 157.572 6.54477 158.161 6.9307C158.749 7.31658 159.202 7.85713 159.52 8.55232C159.837 9.24748 159.996 10.063 159.996 10.9989V11.5081H153.698C153.814 12.2088 154.097 12.7602 154.548 13.1625C155 13.5648 155.571 13.7659 156.26 13.766C156.813 13.766 157.289 13.6839 157.689 13.5196C158.088 13.3554 158.463 13.1063 158.814 12.7724L159.799 13.9794C158.819 14.8771 157.618 15.326 156.195 15.3259ZM157.549 8.50718C157.161 8.11027 156.651 7.91184 156.022 7.91189C155.409 7.91189 154.896 8.11439 154.483 8.51941C154.069 8.92464 153.808 9.46931 153.698 10.1534H158.214C158.159 9.45273 157.938 8.90398 157.549 8.50716V8.50718Z" fill="currentColor"></path><path d="M5.26022 3.23511C5.25436 3.23511 5.24854 3.23513 5.24268 3.23516L5.21875 5.21191C5.22423 5.21185 5.22969 5.2118 5.23518 5.2118C6.53629 5.2118 7.54551 6.23768 9.73906 9.93252L9.87278 10.1575L9.88153 10.1722L11.1094 8.32979L11.1009 8.31556C10.812 7.84556 10.5344 7.41312 10.2681 7.01826C9.95934 6.56075 9.66404 6.15204 9.37746 5.78713C7.92635 3.93952 6.71249 3.23511 5.26022 3.23511Z" fill="url(#paint0_linear_627_396207)"></path><path d="M5.24198 3.23516C3.78266 3.24267 2.49251 4.18633 1.56092 5.63032C1.55819 5.63455 1.55546 5.63879 1.55273 5.64302L3.26279 6.57377C3.26556 6.56957 3.26836 6.56535 3.27114 6.56117C3.81514 5.7421 4.49212 5.21969 5.21805 5.21191C5.22353 5.21185 5.229 5.21181 5.23448 5.21181L5.2595 3.23511C5.25364 3.23511 5.24783 3.23513 5.24198 3.23516Z" fill="url(#paint1_linear_627_396207)"></path><path d="M1.56088 5.63037C1.55816 5.6346 1.55543 5.63884 1.5527 5.64307C0.94054 6.596 0.484192 7.76537 0.237567 9.02689C0.236499 9.03235 0.235435 9.03781 0.234375 9.04329L2.15555 9.49659C2.15655 9.49111 2.15756 9.48562 2.15857 9.48015C2.36393 8.37149 2.75488 7.34323 3.26274 6.57382C3.26552 6.56962 3.26831 6.5654 3.2711 6.56122L1.56088 5.63037Z" fill="url(#paint2_linear_627_396207)"></path><path d="M2.15979 9.48011L0.238778 9.02686C0.23771 9.03231 0.236646 9.03778 0.235585 9.04325C0.101104 9.73704 0.0326863 10.442 0.03125 11.1487C0.03125 11.1544 0.03125 11.1601 0.03125 11.1658L2.00149 11.3421C2.00133 11.3364 2.00117 11.3307 2.00103 11.3249C2.00007 11.284 1.99958 11.2424 1.99956 11.2003C2.00054 10.6288 2.05316 10.0586 2.15678 9.49655C2.15776 9.49107 2.15878 9.48558 2.15979 9.48011Z" fill="url(#paint3_linear_627_396207)"></path><path d="M2.06148 11.9568C2.02614 11.7537 2.00611 11.5482 2.00156 11.3421C2.0014 11.3363 2.00124 11.3307 2.0011 11.3249L0.031335 11.1487C0.031335 11.1544 0.031335 11.1601 0.031335 11.1658V11.1669C0.0292535 11.5801 0.0653944 11.9925 0.139296 12.399C0.140327 12.4045 0.14134 12.4099 0.142386 12.4154L2.06448 11.9732C2.06345 11.9678 2.06247 11.9623 2.06148 11.9568Z" fill="url(#paint4_linear_627_396207)"></path><path d="M2.50976 12.9765C2.29536 12.7425 2.14362 12.405 2.06386 11.9732C2.06285 11.9678 2.06187 11.9623 2.06088 11.9568L0.138672 12.399C0.139703 12.4045 0.140716 12.4099 0.141762 12.4154C0.28705 13.1782 0.571996 13.8139 0.980035 14.2949C0.983663 14.2991 0.987305 14.3034 0.990959 14.3077L2.52121 12.9888C2.51738 12.9848 2.51355 12.9807 2.50976 12.9765Z" fill="url(#paint5_linear_627_396207)"></path><path d="M8.20487 7.50854C7.04655 9.28523 6.34486 10.3996 6.34486 10.3996C4.80187 12.8183 4.26806 13.3604 3.409 13.3604C3.05054 13.3604 2.75107 13.2328 2.52164 12.9888C2.51782 12.9848 2.51398 12.9807 2.51019 12.9765L0.980469 14.2949C0.984097 14.2991 0.987738 14.3034 0.991392 14.3077C1.5548 14.9644 2.35009 15.3288 3.33393 15.3288C4.82242 15.3288 5.89296 14.6271 7.79608 11.3004C7.79608 11.3004 8.58943 9.8994 9.1352 8.93436C8.79713 8.38854 8.48948 7.91597 8.20487 7.50854Z" fill="#0082FB"></path><path d="M10.2688 4.7041C10.2649 4.70825 10.261 4.71248 10.2571 4.71664C9.94322 5.05596 9.64935 5.41323 9.37695 5.78663C9.66354 6.15154 9.95939 6.56105 10.2682 7.01855C10.6321 6.45684 10.9718 6.00189 11.3048 5.6532C11.3087 5.64907 11.3126 5.64504 11.3166 5.64094L10.2688 4.7041Z" fill="url(#paint6_linear_627_396207)"></path><path d="M15.8912 4.53007C15.0834 3.71396 14.1202 3.23511 13.0905 3.23511C12.0047 3.23511 11.0914 3.83012 10.2677 4.70423C10.2637 4.70837 10.2598 4.71261 10.2559 4.71677L11.3036 5.65333C11.3075 5.6492 11.3114 5.64517 11.3154 5.64107C11.858 5.0766 12.3832 4.79478 12.9654 4.79478H12.9654C13.592 4.79478 14.1786 5.08975 14.6867 5.60687C14.6906 5.61092 14.6946 5.61494 14.6986 5.61902L15.9032 4.54221C15.8992 4.53815 15.8952 4.53412 15.8912 4.53007Z" fill="#0082FB"></path><path d="M18.2273 10.8885C18.1821 8.26813 17.2651 5.92556 15.904 4.54218C15.9 4.53811 15.896 4.53408 15.892 4.53003L14.6875 5.60684C14.6915 5.61089 14.6954 5.61491 14.6994 5.61899C15.7233 6.67077 16.4256 8.6271 16.4895 10.8879C16.4897 10.8936 16.4898 10.8993 16.49 10.905L18.2276 10.9056C18.2275 10.8999 18.2274 10.8942 18.2273 10.8885Z" fill="url(#paint7_linear_627_396207)"></path><path d="M18.2262 10.9056C18.2261 10.8999 18.226 10.8942 18.2259 10.8885L16.4881 10.8879C16.4883 10.8936 16.4884 10.8993 16.4886 10.905C16.4914 11.0111 16.4928 11.1179 16.4928 11.2253C16.4928 11.8417 16.4007 12.34 16.2135 12.6997C16.2107 12.705 16.2079 12.7104 16.2051 12.7157L17.5007 14.0632C17.504 14.0583 17.5071 14.0535 17.5103 14.0486C17.9807 13.3228 18.2276 12.3145 18.2276 11.0918C18.2276 11.0296 18.2272 10.9675 18.2262 10.9056Z" fill="url(#paint8_linear_627_396207)"></path><path d="M16.2158 12.6997C16.213 12.705 16.2102 12.7104 16.2074 12.7157C16.0453 13.0189 15.814 13.2212 15.5117 13.3096L16.1024 15.1711C16.1806 15.1445 16.2567 15.1147 16.3308 15.0816C16.353 15.0718 16.3749 15.0616 16.3967 15.0512C16.4092 15.0452 16.4217 15.0391 16.4341 15.0329C16.8281 14.8341 17.1672 14.5417 17.4217 14.1812C17.438 14.1587 17.4541 14.1359 17.47 14.1127C17.4811 14.0963 17.4921 14.0798 17.5031 14.0632C17.5063 14.0583 17.5094 14.0534 17.5126 14.0485L16.2158 12.6997Z" fill="url(#paint9_linear_627_396207)"></path><path d="M15.1349 13.3603C14.9481 13.3648 14.7626 13.3286 14.5911 13.2544L13.9863 15.1602C14.3262 15.2763 14.6889 15.3287 15.0932 15.3287C15.4415 15.3319 15.7878 15.2768 16.1179 15.1654L15.5273 13.3046C15.4001 13.3427 15.2678 13.3615 15.1349 13.3603Z" fill="url(#paint10_linear_627_396207)"></path><path d="M13.9243 12.7085C13.9206 12.7042 13.9168 12.6999 13.9131 12.6956L12.5215 14.1429C12.5254 14.147 12.5293 14.1512 12.5332 14.1553C13.0167 14.6706 13.4784 14.9903 14.0021 15.1657L14.6064 13.2613C14.3857 13.1665 14.1723 12.9947 13.9243 12.7085Z" fill="url(#paint11_linear_627_396207)"></path><path d="M13.9142 12.6956C13.4968 12.2101 12.9804 11.4019 12.1682 10.095L11.1097 8.32966L11.1012 8.31543L9.87305 10.1573L9.8818 10.172L10.6318 11.4337C11.3588 12.6503 11.9511 13.5304 12.5226 14.1428C12.5265 14.147 12.5304 14.1512 12.5343 14.1553L13.9254 12.7085C13.9217 12.7042 13.918 12.6999 13.9142 12.6956Z" fill="url(#paint12_linear_627_396207)"></path><defs><linearGradient id="paint0_linear_627_396207" x1="10.2933" y1="9.42293" x2="6.21654" y2="4.08099" gradientUnits="userSpaceOnUse"><stop offset="0.0006" stop-color="#0867DF"></stop><stop offset="0.4539" stop-color="#0668E1"></stop><stop offset="0.8591" stop-color="#0064E0"></stop></linearGradient><linearGradient id="paint1_linear_627_396207" x1="2.35598" y1="5.96246" x2="5.15084" y2="3.84063" gradientUnits="userSpaceOnUse"><stop offset="0.1323" stop-color="#0064DF"></stop><stop offset="0.9988" stop-color="#0064E0"></stop></linearGradient><linearGradient id="paint2_linear_627_396207" x1="1.17132" y1="9.07623" x2="2.29244" y2="6.25404" gradientUnits="userSpaceOnUse"><stop offset="0.0147" stop-color="#0072EC"></stop><stop offset="0.6881" stop-color="#0064DF"></stop></linearGradient><linearGradient id="paint3_linear_627_396207" x1="1.02028" y1="11.115" x2="1.15" y2="9.39138" gradientUnits="userSpaceOnUse"><stop offset="0.0731" stop-color="#007CF6"></stop><stop offset="0.9943" stop-color="#0072EC"></stop></linearGradient><linearGradient id="paint4_linear_627_396207" x1="1.0917" y1="12.0512" x2="0.998912" y2="11.3606" gradientUnits="userSpaceOnUse"><stop offset="0.0731" stop-color="#007FF9"></stop><stop offset="1" stop-color="#007CF6"></stop></linearGradient><linearGradient id="paint5_linear_627_396207" x1="1.03663" y1="12.2326" x2="1.61491" y2="13.4591" gradientUnits="userSpaceOnUse"><stop offset="0.0731" stop-color="#007FF9"></stop><stop offset="1" stop-color="#0082FB"></stop></linearGradient><linearGradient id="paint6_linear_627_396207" x1="9.92449" y1="6.29781" x2="10.689" y2="5.24046" gradientUnits="userSpaceOnUse"><stop offset="0.2799" stop-color="#007FF8"></stop><stop offset="0.9141" stop-color="#0082FB"></stop></linearGradient><linearGradient id="paint7_linear_627_396207" x1="15.7367" y1="4.92752" x2="17.3361" y2="10.8108" gradientUnits="userSpaceOnUse"><stop stop-color="#0082FB"></stop><stop offset="0.9995" stop-color="#0081FA"></stop></linearGradient><linearGradient id="paint8_linear_627_396207" x1="17.7208" y1="11.0359" x2="16.7086" y2="13.0813" gradientUnits="userSpaceOnUse"><stop offset="0.0619" stop-color="#0081FA"></stop><stop offset="1" stop-color="#0080F9"></stop></linearGradient><linearGradient id="paint9_linear_627_396207" x1="15.9065" y1="14.1657" x2="16.8526" y2="13.5213" gradientUnits="userSpaceOnUse"><stop stop-color="#027AF3"></stop><stop offset="1" stop-color="#0080F9"></stop></linearGradient><linearGradient id="paint10_linear_627_396207" x1="14.4218" y1="14.2915" x2="15.7366" y2="14.2915" gradientUnits="userSpaceOnUse"><stop stop-color="#0377EF"></stop><stop offset="0.9994" stop-color="#0279F1"></stop></linearGradient><linearGradient id="paint11_linear_627_396207" x1="13.2783" y1="13.5675" x2="14.2235" y2="14.1236" gradientUnits="userSpaceOnUse"><stop offset="0.0019" stop-color="#0471E9"></stop><stop offset="1" stop-color="#0377EF"></stop></linearGradient><linearGradient id="paint12_linear_627_396207" x1="10.3961" y1="9.46696" x2="13.424" y2="13.274" gradientUnits="userSpaceOnUse"><stop offset="0.2765" stop-color="#0867DF"></stop><stop offset="1" stop-color="#0471E9"></stop></linearGradient></defs></svg></div></a><div class="text-xs text-left rtl:text-right mt-2 pe-0.5" dir="ltr">Copyright © Meta Platforms, Inc</div><div class="uwu-visible text-xs cursor-pointer hover:text-link hover:dark:text-link-dark hover:underline">no uwu plz</div><div class="uwu-hidden text-xs cursor-pointer hover:text-link hover:dark:text-link-dark hover:underline">uwu?</div><div class="uwu-visible text-xs">Logo by<a href="https://twitter.com/sawaratsuki1004" target="_blank" rel="noopener" class="ms-1">@sawaratsuki1004</a></div></div><div class="flex flex-col"><div><a class="border-b inline-block border-transparent text-md text-secondary dark:text-secondary-dark my-2 font-bold hover:border-gray-10" href="/learn">Learn React</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/learn">Quick Start</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/learn/installation">Installation</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/learn/describing-the-ui">Describing the UI</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/learn/adding-interactivity">Adding Interactivity</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/learn/managing-state">Managing State</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/learn/escape-hatches">Escape Hatches</a></div></div><div class="flex flex-col"><div><a class="border-b inline-block border-transparent text-md text-secondary dark:text-secondary-dark my-2 font-bold hover:border-gray-10" href="/reference/react">API Reference</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/reference/react">React APIs</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/reference/react-dom">React DOM APIs</a></div></div><div class="md:col-start-2 xl:col-start-4 flex flex-col"><div><a class="border-b inline-block border-transparent text-md text-secondary dark:text-secondary-dark my-2 font-bold hover:border-gray-10" href="/community">Community</a></div><div><a href="https://github.com/facebook/react/blob/main/CODE_OF_CONDUCT.md" target="_blank" rel="noopener" class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10">Code of Conduct</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/community/team">Meet the Team</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/community/docs-contributors">Docs Contributors</a></div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/community/acknowledgements">Acknowledgements</a></div></div><div class="flex flex-col"><div class="border-b inline-block border-transparent text-md text-secondary dark:text-secondary-dark my-2 font-bold">More</div><div><a class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10" href="/blog">Blog</a></div><div><a href="https://reactnative.dev/" target="_blank" rel="noopener" class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10">React Native</a></div><div><a href="https://opensource.facebook.com/legal/privacy" target="_blank" rel="noopener" class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10">Privacy</a></div><div><a href="https://opensource.fb.com/legal/terms/" target="_blank" rel="noopener" class="border-b inline-block border-transparent text-sm text-primary dark:text-primary-dark hover:border-gray-10">Terms</a></div><div class="flex flex-row items-center mt-8 gap-x-2"><a href="https://www.facebook.com/react" target="_blank" rel="noopener" aria-label="React on Facebook" class="hover:text-primary dark:text-primary-dark"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1.33em" height="1.33em" fill="currentColor"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.477 2 2 6.477 2 12c0 4.991 3.657 9.128 8.438 9.879V14.89h-2.54V12h2.54V9.797c0-2.506 1.492-3.89 3.777-3.89 1.094 0 2.238.195 2.238.195v2.46h-1.26c-1.243 0-1.63.771-1.63 1.562V12h2.773l-.443 2.89h-2.33v6.989C18.343 21.129 22 16.99 22 12c0-5.523-4.477-10-10-10z"></path></svg></a><a href="https://twitter.com/reactjs" target="_blank" rel="noopener" aria-label="React on Twitter" class="hover:text-primary dark:text-primary-dark"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" height="1.30em" width="1.30em" fill="currentColor"><path fill="none" d="M0 0h24v24H0z"></path><path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"></path></svg></a><a href="https://bsky.app/profile/react.dev" target="_blank" rel="noopener" aria-label="React on Bluesky" class="hover:text-primary dark:text-primary-dark"><svg aria-label="Bluesky" viewBox="0 0 16 16" height="1.25em" width="1.25em" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path class="x19hqcy" d="M3.468 1.948C5.303 3.325 7.276 6.118 8 7.616c.725-1.498 2.697-4.29 4.532-5.668C13.855.955 16 .186 16 2.632c0 .489-.28 4.105-.444 4.692-.572 2.04-2.653 2.561-4.504 2.246 3.236.551 4.06 2.375 2.281 4.2-3.376 3.464-4.852-.87-5.23-1.98-.07-.204-.103-.3-.103-.218 0-.081-.033.014-.102.218-.379 1.11-1.855 5.444-5.231 1.98-1.778-1.825-.955-3.65 2.28-4.2-1.85.315-3.932-.205-4.503-2.246C.28 6.737 0 3.12 0 2.632 0 .186 2.145.955 3.468 1.948Z"></path></svg></a><a href="https://github.com/facebook/react" target="_blank" rel="noopener" aria-label="React on Github" class="hover:text-primary dark:text-primary-dark"><svg xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 -2 24 24" fill="currentColor"><path d="M10 0a10 10 0 0 0-3.16 19.49c.5.1.68-.22.68-.48l-.01-1.7c-2.78.6-3.37-1.34-3.37-1.34-.46-1.16-1.11-1.47-1.11-1.47-.9-.62.07-.6.07-.6 1 .07 1.53 1.03 1.53 1.03.9 1.52 2.34 1.08 2.91.83.1-.65.35-1.09.63-1.34-2.22-.25-4.55-1.11-4.55-4.94 0-1.1.39-1.99 1.03-2.69a3.6 3.6 0 0 1 .1-2.64s.84-.27 2.75 1.02a9.58 9.58 0 0 1 5 0c1.91-1.3 2.75-1.02 2.75-1.02.55 1.37.2 2.4.1 2.64.64.7 1.03 1.6 1.03 2.69 0 3.84-2.34 4.68-4.57 4.93.36.31.68.92.68 1.85l-.01 2.75c0 .26.18.58.69.48A10 10 0 0 0 10 0"></path></svg></a></div></div></div></footer></div></div></main><!--/$--><div class="hidden -mt-16 lg:max-w-custom-xs 2xl:block"><nav role="navigation" class="pt-20 sticky top-0 end-0"><h2 class="mb-3 lg:mb-3 uppercase tracking-wide font-bold text-sm text-secondary dark:text-secondary-dark px-4 w-full">On this page</h2><div class="h-full overflow-y-auto ps-4 max-h-[calc(100vh-7.5rem)]" style="overscroll-behavior:contain"><ul class="space-y-2 pb-16"><li class="text-sm px-2 rounded-s-xl bg-highlight dark:bg-highlight-dark"><a class="text-link dark:text-link-dark font-bold block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#">Overview</a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#what-does-the-compiler-do">What does the compiler do? </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#should-i-try-out-the-compiler">Should I try out the compiler? </a></li><li class="text-sm px-2 rounded-s-xl"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#getting-started">Getting Started </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#installing-eslint-plugin-react-compiler">Installing eslint-plugin-react-compiler </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#using-the-compiler-effectively">Rolling out the compiler to your codebase </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#using-react-compiler-with-react-17-or-18">Using React Compiler with React 17 or 18 </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#using-the-compiler-on-libraries">Using the compiler on libraries </a></li><li class="text-sm px-2 rounded-s-xl"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#installation">Usage </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-babel">Babel </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-vite">Vite </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-nextjs">Next.js </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-remix">Remix </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-webpack">Webpack </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-expo">Expo </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-react-native-metro">Metro (React Native) </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-rspack">Rspack </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#usage-with-rsbuild">Rsbuild </a></li><li class="text-sm px-2 rounded-s-xl"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#troubleshooting">Troubleshooting </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#what-does-the-compiler-assume">What does the compiler assume? </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#how-do-i-know-my-components-have-been-optimized">How do I know my components have been optimized? </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#something-is-not-working-after-compilation">Something is not working after compilation </a></li><li class="text-sm px-2 rounded-s-xl ps-4"><a class="text-secondary dark:text-secondary-dark block hover:text-link dark:hover:text-link-dark leading-normal py-2" href="#other-issues">Other issues </a></li></ul></div></nav></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"toc":"[{\"url\":\"#\",\"text\":\"Overview\",\"depth\":2},{\"url\":\"#what-does-the-compiler-do\",\"depth\":3,\"text\":\"What does the compiler do? \"},{\"url\":\"#should-i-try-out-the-compiler\",\"depth\":3,\"text\":\"Should I try out the compiler? \"},{\"url\":\"#getting-started\",\"depth\":2,\"text\":\"Getting Started \"},{\"url\":\"#installing-eslint-plugin-react-compiler\",\"depth\":3,\"text\":\"Installing eslint-plugin-react-compiler \"},{\"url\":\"#using-the-compiler-effectively\",\"depth\":3,\"text\":\"Rolling out the compiler to your codebase \"},{\"url\":\"#using-react-compiler-with-react-17-or-18\",\"depth\":3,\"text\":\"Using React Compiler with React 17 or 18 \"},{\"url\":\"#using-the-compiler-on-libraries\",\"depth\":3,\"text\":\"Using the compiler on libraries \"},{\"url\":\"#installation\",\"depth\":2,\"text\":\"Usage \"},{\"url\":\"#usage-with-babel\",\"depth\":3,\"text\":\"Babel \"},{\"url\":\"#usage-with-vite\",\"depth\":3,\"text\":\"Vite \"},{\"url\":\"#usage-with-nextjs\",\"depth\":3,\"text\":\"Next.js \"},{\"url\":\"#usage-with-remix\",\"depth\":3,\"text\":\"Remix \"},{\"url\":\"#usage-with-webpack\",\"depth\":3,\"text\":\"Webpack \"},{\"url\":\"#usage-with-expo\",\"depth\":3,\"text\":\"Expo \"},{\"url\":\"#usage-with-react-native-metro\",\"depth\":3,\"text\":\"Metro (React Native) \"},{\"url\":\"#usage-with-rspack\",\"depth\":3,\"text\":\"Rspack \"},{\"url\":\"#usage-with-rsbuild\",\"depth\":3,\"text\":\"Rsbuild \"},{\"url\":\"#troubleshooting\",\"depth\":2,\"text\":\"Troubleshooting \"},{\"url\":\"#what-does-the-compiler-assume\",\"depth\":3,\"text\":\"What does the compiler assume? \"},{\"url\":\"#how-do-i-know-my-components-have-been-optimized\",\"depth\":3,\"text\":\"How do I know my components have been optimized? \"},{\"url\":\"#something-is-not-working-after-compilation\",\"depth\":3,\"text\":\"Something is not working after compilation \"},{\"url\":\"#other-issues\",\"depth\":3,\"text\":\"Other issues \"}]","content":"[[\"$r\",\"MaxWidth\",\"last\",{\"children\":[[\"$r\",\"Intro\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"This page will give you an introduction to React Compiler and how to try it out successfully.\"}]}],\"\\n\",[\"$r\",\"Wip\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":[\"These docs are still a work in progress. More documentation is available in the \",[\"$r\",\"a\",null,{\"href\":\"https://github.com/reactwg/react-compiler/discussions\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"React Compiler Working Group repo\"}],\", and will be upstreamed into these docs when they are more stable.\"]}]}],\"\\n\",[\"$r\",\"YouWillLearn\",null,{\"children\":[\"$r\",\"ul\",null,{\"children\":[\"\\n\",[\"$r\",\"li\",null,{\"children\":\"Getting started with the compiler\"}],\"\\n\",[\"$r\",\"li\",null,{\"children\":\"Installing the compiler and ESLint plugin\"}],\"\\n\",[\"$r\",\"li\",null,{\"children\":\"Troubleshooting\"}],\"\\n\"]}]}],\"\\n\",[\"$r\",\"Note\",null,{\"children\":[[\"$r\",\"p\",null,{\"children\":[\"React Compiler is a new compiler currently in Beta, that we’ve open sourced to get early feedback from the community. While it has been used in production at companies like Meta, rolling out the compiler to production for your app will depend on the health of your codebase and how well you’ve followed the \",[\"$r\",\"a\",null,{\"href\":\"/reference/rules\",\"children\":\"Rules of React\"}],\".\"]}],[\"$r\",\"p\",null,{\"children\":[\"The latest Beta release can be found with the \",[\"$r\",\"code\",null,{\"children\":\"@beta\"}],\" tag, and daily experimental releases with \",[\"$r\",\"code\",null,{\"children\":\"@experimental\"}],\".\"]}]]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"React Compiler is a new compiler that we’ve open sourced to get early feedback from the community. It is a build-time only tool that automatically optimizes your React app. It works with plain JavaScript, and understands the \",[\"$r\",\"a\",null,{\"href\":\"/reference/rules\",\"children\":\"Rules of React\"}],\", so you don’t need to rewrite any code to use it.\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"The compiler also includes an \",[\"$r\",\"a\",null,{\"href\":\"#installing-eslint-plugin-react-compiler\",\"children\":\"ESLint plugin\"}],\" that surfaces the analysis from the compiler right in your editor. \",[\"$r\",\"strong\",null,{\"children\":\"We strongly recommend everyone use the linter today.\"}],\" The linter does not require that you have the compiler installed, so you can use it even if you are not ready to try out the compiler.\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"The compiler is currently released as \",[\"$r\",\"code\",null,{\"children\":\"beta\"}],\", and is available to try out on React 17+ apps and libraries. To install the Beta:\"]}],\"\\n\",[\"$r\",\"TerminalBlock\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"npm install -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"Or, if you’re using Yarn:\"}],\"\\n\",[\"$r\",\"TerminalBlock\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"yarn add -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"If you are not using React 19 yet, please see \",[\"$r\",\"a\",null,{\"href\":\"#using-react-compiler-with-react-17-or-18\",\"children\":\"the section below\"}],\" for further instructions.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"what-does-the-compiler-do\",\"children\":\"What does the compiler do? \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"In order to optimize applications, React Compiler automatically memoizes your code. You may be familiar today with memoization through APIs such as \",[\"$r\",\"code\",null,{\"children\":\"useMemo\"}],\", \",[\"$r\",\"code\",null,{\"children\":\"useCallback\"}],\", and \",[\"$r\",\"code\",null,{\"children\":\"React.memo\"}],\". With these APIs you can tell React that certain parts of your application don’t need to recompute if their inputs haven’t changed, reducing work on updates. While powerful, it’s easy to forget to apply memoization or apply them incorrectly. This can lead to inefficient updates as React has to check parts of your UI that don’t have any \",[\"$r\",\"em\",null,{\"children\":\"meaningful\"}],\" changes.\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"The compiler uses its knowledge of JavaScript and React’s rules to automatically memoize values or groups of values within your components and hooks. If it detects breakages of the rules, it will automatically skip over just those components or hooks, and continue safely compiling other code.\"}],\"\\n\",[\"$r\",\"Note\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"React Compiler can statically detect when Rules of React are broken, and safely opt-out of optimizing just the affected components or hooks. It is not necessary for the compiler to optimize 100% of your codebase.\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"If your codebase is already very well-memoized, you might not expect to see major performance improvements with the compiler. However, in practice memoizing the correct dependencies that cause performance issues is tricky to get right by hand.\"}],\"\\n\",[\"$r\",\"DeepDive\",null,{\"children\":[[\"$r\",\"h4\",null,{\"id\":\"what-kind-of-memoization-does-react-compiler-add\",\"children\":\"What kind of memoization does React Compiler add? \"}],[\"$r\",\"p\",null,{\"children\":[\"The initial release of React Compiler is primarily focused on \",[\"$r\",\"strong\",null,{\"children\":\"improving update performance\"}],\" (re-rendering existing components), so it focuses on these two use cases:\"]}],[\"$r\",\"ol\",null,{\"children\":[\"\\n\",[\"$r\",\"li\",null,{\"children\":[[\"$r\",\"strong\",null,{\"children\":\"Skipping cascading re-rendering of components\"}],\"\\n\",[\"$r\",\"ul\",null,{\"children\":[\"\\n\",[\"$r\",\"li\",null,{\"children\":[\"Re-rendering \",[\"$r\",\"code\",null,{\"children\":\"\u003cParent /\u003e\"}],\" causes many components in its component tree to re-render, even though only \",[\"$r\",\"code\",null,{\"children\":\"\u003cParent /\u003e\"}],\" has changed\"]}],\"\\n\"]}],\"\\n\"]}],\"\\n\",[\"$r\",\"li\",null,{\"children\":[[\"$r\",\"strong\",null,{\"children\":\"Skipping expensive calculations from outside of React\"}],\"\\n\",[\"$r\",\"ul\",null,{\"children\":[\"\\n\",[\"$r\",\"li\",null,{\"children\":[\"For example, calling \",[\"$r\",\"code\",null,{\"children\":\"expensivelyProcessAReallyLargeArrayOfObjects()\"}],\" inside of your component or hook that needs that data\"]}],\"\\n\"]}],\"\\n\"]}],\"\\n\"]}],[\"$r\",\"h4\",null,{\"id\":\"optimizing-re-renders\",\"children\":\"Optimizing Re-renders \"}],[\"$r\",\"p\",null,{\"children\":[\"React lets you express your UI as a function of their current state (more concretely: their props, state, and context). In its current implementation, when a component’s state changes, React will re-render that component \",[\"$r\",\"em\",null,{\"children\":\"and all of its children\"}],\" — unless you have applied some form of manual memoization with \",[\"$r\",\"code\",null,{\"children\":\"useMemo()\"}],\", \",[\"$r\",\"code\",null,{\"children\":\"useCallback()\"}],\", or \",[\"$r\",\"code\",null,{\"children\":\"React.memo()\"}],\". For example, in the following example, \",[\"$r\",\"code\",null,{\"children\":\"\u003cMessageButton\u003e\"}],\" will re-render whenever \",[\"$r\",\"code\",null,{\"children\":\"\u003cFriendList\u003e\"}],\"’s state changes:\"]}],[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-javascript\",\"children\":\"function FriendList({ friends }) {\\n const onlineCount = useFriendOnlineCount();\\n if (friends.length === 0) {\\n return \u003cNoFriends /\u003e;\\n }\\n return (\\n \u003cdiv\u003e\\n \u003cspan\u003e{onlineCount} online\u003c/span\u003e\\n {friends.map((friend) =\u003e (\\n \u003cFriendListCard key={friend.id} friend={friend} /\u003e\\n ))}\\n \u003cMessageButton /\u003e\\n \u003c/div\u003e\\n );\\n}\\n\"}]}],[\"$r\",\"p\",null,{\"children\":[\"$r\",\"a\",null,{\"href\":\"https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAYjHgpgCYAyeYOAFMEWuZVWEQL4CURwADrEicQgyKEANnkwIAwtEw4iAXiJQwCMhWoB5TDLmKsTXgG5hRInjRFGbXZwB0UygHMcACzWr1ABn4hEWsYBBxYYgAeADkIHQ4uAHoAPksRbisiMIiYYkYs6yiqPAA3FMLrIiiwAAcAQ0wU4GlZBSUcbklDNqikusaKkKrgR0TnAFt62sYHdmp+VRT7SqrqhOo6Bnl6mCoiAGsEAE9VUfmqZzwqLrHqM7ubolTVol5eTOGigFkEMDB6u4EAAhKA4HCEZ5DNZ9ErlLIWYTcEDcIA\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":[\"$r\",\"em\",null,{\"children\":\"See this example in the React Compiler Playground\"}]}]}],[\"$r\",\"p\",null,{\"children\":[\"React Compiler automatically applies the equivalent of manual memoization, ensuring that only the relevant parts of an app re-render as state changes, which is sometimes referred to as “fine-grained reactivity”. In the above example, React Compiler determines that the return value of \",[\"$r\",\"code\",null,{\"children\":\"\u003cFriendListCard /\u003e\"}],\" can be reused even as \",[\"$r\",\"code\",null,{\"children\":\"friends\"}],\" changes, and can avoid recreating this JSX \",[\"$r\",\"em\",null,{\"children\":\"and\"}],\" avoid re-rendering \",[\"$r\",\"code\",null,{\"children\":\"\u003cMessageButton\u003e\"}],\" as the count changes.\"]}],[\"$r\",\"h4\",null,{\"id\":\"expensive-calculations-also-get-memoized\",\"children\":\"Expensive calculations also get memoized \"}],[\"$r\",\"p\",null,{\"children\":\"The compiler can also automatically memoize for expensive calculations used during rendering:\"}],[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"children\":\"// **Not** memoized by React Compiler, since this is not a component or hook\\nfunction expensivelyProcessAReallyLargeArrayOfObjects() { /* ... */ }\\n\\n// Memoized by React Compiler since this is a component\\nfunction TableContainer({ items }) {\\n // This function call would be memoized:\\n const data = expensivelyProcessAReallyLargeArrayOfObjects(items);\\n // ...\\n}\\n\"}]}],[\"$r\",\"p\",null,{\"children\":[\"$r\",\"a\",null,{\"href\":\"https://playground.react.dev/#N4Igzg9grgTgxgUxALhAejQAgFTYHIQAuumAtgqRAJYBeCAJpgEYCemASggIZyGYDCEUgAcqAGwQwANJjBUAdokyEAFlTCZ1meUUxdMcIcIjyE8vhBiYVECAGsAOvIBmURYSonMCAB7CzcgBuCGIsAAowEIhgYACCnFxioQAyXDAA5gixMDBcLADyzvlMAFYIvGAAFACUmMCYaNiYAHStOFgAvk5OGJgAshTUdIysHNy8AkbikrIKSqpaWvqGIiZmhE6u7p7ymAAqXEwSguZcCpKV9VSEFBodtcBOmAYmYHz0XIT6ALzefgFUYKhCJRBAxeLcJIsVIZLI5PKFYplCqVa63aoAbm6u0wMAQhFguwAPPRAQA+YAfL4dIloUmBMlODogDpAA\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":[\"$r\",\"em\",null,{\"children\":\"See this example in the React Compiler Playground\"}]}]}],[\"$r\",\"p\",null,{\"children\":[\"However, if \",[\"$r\",\"code\",null,{\"children\":\"expensivelyProcessAReallyLargeArrayOfObjects\"}],\" is truly an expensive function, you may want to consider implementing its own memoization outside of React, because:\"]}],[\"$r\",\"ul\",null,{\"children\":[\"\\n\",[\"$r\",\"li\",null,{\"children\":\"React Compiler only memoizes React components and hooks, not every function\"}],\"\\n\",[\"$r\",\"li\",null,{\"children\":\"React Compiler’s memoization is not shared across multiple components or hooks\"}],\"\\n\"]}],[\"$r\",\"p\",null,{\"children\":[\"So if \",[\"$r\",\"code\",null,{\"children\":\"expensivelyProcessAReallyLargeArrayOfObjects\"}],\" was used in many different components, even if the same exact items were passed down, that expensive calculation would be run repeatedly. We recommend \",[\"$r\",\"a\",null,{\"href\":\"https://react.dev/reference/react/useMemo#how-to-tell-if-a-calculation-is-expensive\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"profiling\"}],\" first to see if it really is that expensive before making code more complicated.\"]}]]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"should-i-try-out-the-compiler\",\"children\":\"Should I try out the compiler? \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Please note that the compiler is still in Beta and has many rough edges. While it has been used in production at companies like Meta, rolling out the compiler to production for your app will depend on the health of your codebase and how well you’ve followed the \",[\"$r\",\"a\",null,{\"href\":\"/reference/rules\",\"children\":\"Rules of React\"}],\".\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[[\"$r\",\"strong\",null,{\"children\":\"You don’t have to rush into using the compiler now. It’s okay to wait until it reaches a stable release before adopting it.\"}],\" However, we do appreciate trying it out in small experiments in your apps so that you can \",[\"$r\",\"a\",null,{\"href\":\"#reporting-issues\",\"children\":\"provide feedback\"}],\" to us to help make the compiler better.\"]}],\"\\n\",[\"$r\",\"h2\",null,{\"id\":\"getting-started\",\"children\":\"Getting Started \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"In addition to these docs, we recommend checking the \",[\"$r\",\"a\",null,{\"href\":\"https://github.com/reactwg/react-compiler\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"React Compiler Working Group\"}],\" for additional information and discussion about the compiler.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"installing-eslint-plugin-react-compiler\",\"children\":\"Installing eslint-plugin-react-compiler \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"React Compiler also powers an ESLint plugin. The ESLint plugin can be used \",[\"$r\",\"strong\",null,{\"children\":\"independently\"}],\" of the compiler, meaning you can use the ESLint plugin even if you don’t use the compiler.\"]}],\"\\n\",[\"$r\",\"TerminalBlock\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"npm install -D eslint-plugin-react-compiler@beta\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"Then, add it to your ESLint config:\"}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"children\":\"import reactCompiler from 'eslint-plugin-react-compiler'\\n\\nexport default [\\n {\\n plugins: {\\n 'react-compiler': reactCompiler,\\n },\\n rules: {\\n 'react-compiler/react-compiler': 'error',\\n },\\n },\\n]\\n\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"Or, in the deprecated eslintrc config format:\"}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"children\":\"module.exports = {\\n plugins: [\\n 'eslint-plugin-react-compiler',\\n ],\\n rules: {\\n 'react-compiler/react-compiler': 'error',\\n },\\n}\\n\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"The ESLint plugin will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase.\"}],\"\\n\",[\"$r\",\"Note\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":[[\"$r\",\"strong\",null,{\"children\":\"You don’t have to fix all ESLint violations straight away.\"}],\" You can address them at your own pace to increase the amount of components and hooks being optimized, but it is not required to fix everything before you can use the compiler.\"]}]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"using-the-compiler-effectively\",\"children\":\"Rolling out the compiler to your codebase \"}],\"\\n\",[\"$r\",\"h4\",null,{\"id\":\"existing-projects\",\"children\":\"Existing projects \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"The compiler is designed to compile functional components and hooks that follow the \",[\"$r\",\"a\",null,{\"href\":\"/reference/rules\",\"children\":\"Rules of React\"}],\". It can also handle code that breaks those rules by bailing out (skipping over) those components or hooks. However, due to the flexible nature of JavaScript, the compiler cannot catch every possible violation and may compile with false negatives: that is, the compiler may accidentally compile a component/hook that breaks the Rules of React which can lead to undefined behavior.\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"For this reason, to adopt the compiler successfully on existing projects, we recommend running it on a small directory in your product code first. You can do this by configuring the compiler to only run on a specific set of directories:\"}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"meta\":\"{3}\",\"children\":\"const ReactCompilerConfig = {\\n sources: (filename) =\u003e {\\n return filename.indexOf('src/path/to/dir') !== -1;\\n },\\n};\\n\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"When you have more confidence with rolling out the compiler, you can expand coverage to other directories as well and slowly roll it out to your whole app.\"}],\"\\n\",[\"$r\",\"h4\",null,{\"id\":\"new-projects\",\"children\":\"New projects \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"If you’re starting a new project, you can enable the compiler on your entire codebase, which is the default behavior.\"}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"using-react-compiler-with-react-17-or-18\",\"children\":\"Using React Compiler with React 17 or 18 \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"React Compiler works best with React 19 RC. If you are unable to upgrade, you can install the extra \",[\"$r\",\"code\",null,{\"children\":\"react-compiler-runtime\"}],\" package which will allow the compiled code to run on versions prior to 19. However, note that the minimum supported version is 17.\"]}],\"\\n\",[\"$r\",\"TerminalBlock\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"npm install react-compiler-runtime@beta\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"You should also add the correct \",[\"$r\",\"code\",null,{\"children\":\"target\"}],\" to your compiler config, where \",[\"$r\",\"code\",null,{\"children\":\"target\"}],\" is the major version of React you are targeting:\"]}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"meta\":\"{3}\",\"children\":\"// babel.config.js\\nconst ReactCompilerConfig = {\\n target: '18' // '17' | '18' | '19'\\n};\\n\\nmodule.exports = function () {\\n return {\\n plugins: [\\n ['babel-plugin-react-compiler', ReactCompilerConfig],\\n ],\\n };\\n};\\n\"}]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"using-the-compiler-on-libraries\",\"children\":\"Using the compiler on libraries \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"React Compiler can also be used to compile libraries. Because React Compiler needs to run on the original source code prior to any code transformations, it is not possible for an application’s build pipeline to compile the libraries they use. Hence, our recommendation is for library maintainers to independently compile and test their libraries with the compiler, and ship compiled code to npm.\"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Because your code is pre-compiled, users of your library will not need to have the compiler enabled in order to benefit from the automatic memoization applied to your library. If your library targets apps not yet on React 19, specify a minimum \",[\"$r\",\"a\",null,{\"href\":\"#using-react-compiler-with-react-17-or-18\",\"children\":[[\"$r\",\"code\",null,{\"children\":\"target\"}],\" and add \",[\"$r\",\"code\",null,{\"children\":\"react-compiler-runtime\"}],\" as a direct dependency\"]}],\". The runtime package will use the correct implementation of APIs depending on the application’s version, and polyfill the missing APIs if necessary.\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Library code can often require more complex patterns and usage of escape hatches. For this reason, we recommend ensuring that you have sufficient testing in order to identify any issues that might arise from using the compiler on your library. If you identify any issues, you can always opt-out the specific components or hooks with the \",[\"$r\",\"a\",null,{\"href\":\"#something-is-not-working-after-compilation\",\"children\":[[\"$r\",\"code\",null,{\"children\":\"'use no memo'\"}],\" directive\"]}],\".\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Similarly to apps, it is not necessary to fully compile 100% of your components or hooks to see benefits in your library. A good starting point might be to identify the most performance sensitive parts of your library and ensuring that they don’t break the \",[\"$r\",\"a\",null,{\"href\":\"/reference/rules\",\"children\":\"Rules of React\"}],\", which you can use \",[\"$r\",\"code\",null,{\"children\":\"eslint-plugin-react-compiler\"}],\" to identify.\"]}],\"\\n\",[\"$r\",\"h2\",null,{\"id\":\"installation\",\"children\":\"Usage \"}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-babel\",\"children\":\"Babel \"}],\"\\n\",[\"$r\",\"TerminalBlock\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"npm install babel-plugin-react-compiler@beta\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"The compiler includes a Babel plugin which you can use in your build pipeline to run the compiler.\"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"After installing, add it to your Babel config. Please note that it’s critical that the compiler run \",[\"$r\",\"strong\",null,{\"children\":\"first\"}],\" in the pipeline:\"]}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"meta\":\"{7}\",\"children\":\"// babel.config.js\\nconst ReactCompilerConfig = { /* ... */ };\\n\\nmodule.exports = function () {\\n return {\\n plugins: [\\n ['babel-plugin-react-compiler', ReactCompilerConfig], // must run first!\\n // ...\\n ],\\n };\\n};\\n\"}]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[[\"$r\",\"code\",null,{\"children\":\"babel-plugin-react-compiler\"}],\" should run first before other Babel plugins as the compiler requires the input source information for sound analysis.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-vite\",\"children\":\"Vite \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"If you use Vite, you can add the plugin to vite-plugin-react:\"}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"meta\":\"{10}\",\"children\":\"// vite.config.js\\nconst ReactCompilerConfig = { /* ... */ };\\n\\nexport default defineConfig(() =\u003e {\\n return {\\n plugins: [\\n react({\\n babel: {\\n plugins: [\\n [\\\"babel-plugin-react-compiler\\\", ReactCompilerConfig],\\n ],\\n },\\n }),\\n ],\\n // ...\\n };\\n});\\n\"}]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-nextjs\",\"children\":\"Next.js \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Please refer to the \",[\"$r\",\"a\",null,{\"href\":\"https://nextjs.org/docs/app/api-reference/next-config-js/reactCompiler\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"Next.js docs\"}],\" for more information.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-remix\",\"children\":\"Remix \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Install \",[\"$r\",\"code\",null,{\"children\":\"vite-plugin-babel\"}],\", and add the compiler’s Babel plugin to it:\"]}],\"\\n\",[\"$r\",\"TerminalBlock\",null,{\"children\":[\"$r\",\"p\",null,{\"children\":\"npm install vite-plugin-babel\"}]}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"meta\":\"{2,14}\",\"children\":\"// vite.config.js\\nimport babel from \\\"vite-plugin-babel\\\";\\n\\nconst ReactCompilerConfig = { /* ... */ };\\n\\nexport default defineConfig({\\n plugins: [\\n remix({ /* ... */}),\\n babel({\\n filter: /\\\\.[jt]sx?$/,\\n babelConfig: {\\n presets: [\\\"@babel/preset-typescript\\\"], // if you use TypeScript\\n plugins: [\\n [\\\"babel-plugin-react-compiler\\\", ReactCompilerConfig],\\n ],\\n },\\n }),\\n ],\\n});\\n\"}]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-webpack\",\"children\":\"Webpack \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"A community webpack loader is \",[\"$r\",\"a\",null,{\"href\":\"https://github.com/SukkaW/react-compiler-webpack\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"now available here\"}],\".\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-expo\",\"children\":\"Expo \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Please refer to \",[\"$r\",\"a\",null,{\"href\":\"https://docs.expo.dev/guides/react-compiler/\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"Expo’s docs\"}],\" to enable and use the React Compiler in Expo apps.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-react-native-metro\",\"children\":\"Metro (React Native) \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"React Native uses Babel via Metro, so refer to the \",[\"$r\",\"a\",null,{\"href\":\"#usage-with-babel\",\"children\":\"Usage with Babel\"}],\" section for installation instructions.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-rspack\",\"children\":\"Rspack \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Please refer to \",[\"$r\",\"a\",null,{\"href\":\"https://rspack.dev/guide/tech/react#react-compiler\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"Rspack’s docs\"}],\" to enable and use the React Compiler in Rspack apps.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"usage-with-rsbuild\",\"children\":\"Rsbuild \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Please refer to \",[\"$r\",\"a\",null,{\"href\":\"https://rsbuild.dev/guide/framework/react#react-compiler\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"Rsbuild’s docs\"}],\" to enable and use the React Compiler in Rsbuild apps.\"]}],\"\\n\",[\"$r\",\"h2\",null,{\"id\":\"troubleshooting\",\"children\":\"Troubleshooting \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"To report issues, please first create a minimal repro on the \",[\"$r\",\"a\",null,{\"href\":\"https://playground.react.dev/\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"React Compiler Playground\"}],\" and include it in your bug report. You can open issues in the \",[\"$r\",\"a\",null,{\"href\":\"https://github.com/facebook/react/issues\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"facebook/react\"}],\" repo.\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"You can also provide feedback in the React Compiler Working Group by applying to be a member. Please see \",[\"$r\",\"a\",null,{\"href\":\"https://github.com/reactwg/react-compiler\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"the README for more details on joining\"}],\".\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"what-does-the-compiler-assume\",\"children\":\"What does the compiler assume? \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"React Compiler assumes that your code:\"}],\"\\n\",[\"$r\",\"ol\",null,{\"children\":[\"\\n\",[\"$r\",\"li\",null,{\"children\":\"Is valid, semantic JavaScript.\"}],\"\\n\",[\"$r\",\"li\",null,{\"children\":[\"Tests that nullable/optional values and properties are defined before accessing them (for example, by enabling \",[\"$r\",\"a\",null,{\"href\":\"https://www.typescriptlang.org/tsconfig/#strictNullChecks\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":[\"$r\",\"code\",null,{\"children\":\"strictNullChecks\"}]}],\" if using TypeScript), i.e., \",[\"$r\",\"code\",null,{\"children\":\"if (object.nullableProperty) { object.nullableProperty.foo }\"}],\" or with optional-chaining \",[\"$r\",\"code\",null,{\"children\":\"object.nullableProperty?.foo\"}],\".\"]}],\"\\n\",[\"$r\",\"li\",null,{\"children\":[\"Follows the \",[\"$r\",\"a\",null,{\"href\":\"https://react.dev/reference/rules\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"Rules of React\"}],\".\"]}],\"\\n\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"React Compiler can verify many of the Rules of React statically, and will safely skip compilation when it detects an error. To see the errors we recommend also installing \",[\"$r\",\"a\",null,{\"href\":\"https://www.npmjs.com/package/eslint-plugin-react-compiler\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"eslint-plugin-react-compiler\"}],\".\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"how-do-i-know-my-components-have-been-optimized\",\"children\":\"How do I know my components have been optimized? \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[[\"$r\",\"a\",null,{\"href\":\"/learn/react-developer-tools\",\"children\":\"React DevTools\"}],\" (v5.0+) and \",[\"$r\",\"a\",null,{\"href\":\"https://reactnative.dev/docs/react-native-devtools\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"React Native DevTools\"}],\" have built-in support for React Compiler and will display a “Memo ✨” badge next to components that have been optimized by the compiler.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"something-is-not-working-after-compilation\",\"children\":\"Something is not working after compilation \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"If you have eslint-plugin-react-compiler installed, the compiler will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase. \",[\"$r\",\"strong\",null,{\"children\":\"You don’t have to fix all ESLint violations straight away.\"}],\" You can address them at your own pace to increase the amount of components and hooks being optimized.\"]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":\"Due to the flexible and dynamic nature of JavaScript however, it’s not possible to comprehensively detect all cases. Bugs and undefined behavior such as infinite loops may occur in those cases.\"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"If your app doesn’t work properly after compilation and you aren’t seeing any ESLint errors, the compiler may be incorrectly compiling your code. To confirm this, try to make the issue go away by aggressively opting out any component or hook you think might be related via the \",[\"$r\",\"a\",null,{\"href\":\"#opt-out-of-the-compiler-for-a-component\",\"children\":[[\"$r\",\"code\",null,{\"children\":\"\\\"use no memo\\\"\"}],\" directive\"]}],\".\"]}],\"\\n\",[\"$r\",\"pre\",null,{\"children\":[\"$r\",\"code\",null,{\"className\":\"language-js\",\"meta\":\"{2}\",\"children\":\"function SuspiciousComponent() {\\n \\\"use no memo\\\"; // opts out this component from being compiled by React Compiler\\n // ...\\n}\\n\"}]}],\"\\n\",[\"$r\",\"Note\",null,{\"children\":[[\"$r\",\"h4\",null,{\"id\":\"use-no-memo\",\"children\":[[\"$r\",\"code\",null,{\"children\":\"\\\"use no memo\\\"\"}],\" \"]}],[\"$r\",\"p\",null,{\"children\":[[\"$r\",\"code\",null,{\"children\":\"\\\"use no memo\\\"\"}],\" is a \",[\"$r\",\"em\",null,{\"children\":\"temporary\"}],\" escape hatch that lets you opt-out components and hooks from being compiled by the React Compiler. This directive is not meant to be long lived the same way as eg \",[\"$r\",\"a\",null,{\"href\":\"/reference/rsc/use-client\",\"children\":[\"$r\",\"code\",null,{\"children\":\"\\\"use client\\\"\"}]}],\" is.\"]}],[\"$r\",\"p\",null,{\"children\":\"It is not recommended to reach for this directive unless it’s strictly necessary. Once you opt-out a component or hook, it is opted-out forever until the directive is removed. This means that even if you fix the code, the compiler will still skip over compiling it unless you remove the directive.\"}]]}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"When you make the error go away, confirm that removing the opt out directive makes the issue come back. Then share a bug report with us (you can try to reduce it to a small repro, or if it’s open source code you can also just paste the entire source) using the \",[\"$r\",\"a\",null,{\"href\":\"https://playground.react.dev\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"React Compiler Playground\"}],\" so we can identify and help fix the issue.\"]}],\"\\n\",[\"$r\",\"h3\",null,{\"id\":\"other-issues\",\"children\":\"Other issues \"}],\"\\n\",[\"$r\",\"p\",null,{\"children\":[\"Please see \",[\"$r\",\"a\",null,{\"href\":\"https://github.com/reactwg/react-compiler/discussions/7\",\"target\":\"_blank\",\"rel\":\"nofollow noopener noreferrer\",\"children\":\"https://github.com/reactwg/react-compiler/discussions/7\"}],\".\"]}]]}]]","meta":{"title":"React Compiler"},"languages":null},"__N_SSG":true},"page":"/[[...markdownPath]]","query":{"markdownPath":["learn","react-compiler"]},"buildId":"_Fz6u7K2TvuR-_M7SFBnH","isFallback":false,"gsp":true,"scriptLoader":[]}</script></body></html>