diff --git a/src/content/blog/2024/10/21/react-compiler-beta-release.md b/src/content/blog/2024/10/21/react-compiler-beta-release.md index cd49b6eb2f9..750c0f3b8ee 100644 --- a/src/content/blog/2024/10/21/react-compiler-beta-release.md +++ b/src/content/blog/2024/10/21/react-compiler-beta-release.md @@ -12,9 +12,9 @@ October 21, 2024 by [Lauren Tan](https://twitter.com/potetotes). -### React Compiler is now in RC! {/*react-compiler-is-now-in-rc*/} +### React Compiler is now stable! {/*react-compiler-is-now-in-rc*/} -Please see the [RC blog post](/blog/2025/04/21/react-compiler-rc) for details. +Please see the [stable release blog post](/blog/2025/10/07/react-compiler-1) for details. diff --git a/src/content/blog/2025/04/21/react-compiler-rc.md b/src/content/blog/2025/04/21/react-compiler-rc.md deleted file mode 100644 index ce30a8860ac..00000000000 --- a/src/content/blog/2025/04/21/react-compiler-rc.md +++ /dev/null @@ -1,128 +0,0 @@ ---- -title: "React Compiler RC" -author: Lauren Tan and Mofei Zhang -date: 2025/04/21 -description: We are releasing the compiler's first Release Candidate (RC) today. - ---- - -April 21, 2025 by [Lauren Tan](https://x.com/potetotes) and [Mofei Zhang](https://x.com/zmofei). - ---- - - - -The React team is excited to share new updates: - - - -1. We're publishing React Compiler RC today, in preparation of the compiler's stable release. -2. We're merging `eslint-plugin-react-compiler` into `eslint-plugin-react-hooks`. -3. We've added support for swc and are working with oxc to support Babel-free builds. - ---- - -[React Compiler](https://react.dev/learn/react-compiler) is a build-time tool that optimizes your React app through automatic memoization. Last year, we published React Compiler’s [first beta](https://react.dev/blog/2024/10/21/react-compiler-beta-release) and received lots of great feedback and contributions. We’re excited about the wins we’ve seen from folks adopting the compiler (see case studies from [Sanity Studio](https://github.com/reactwg/react-compiler/discussions/33) and [Wakelet](https://github.com/reactwg/react-compiler/discussions/52)) and are working towards a stable release. - -We are releasing the compiler's first Release Candidate (RC) today. The RC is intended to be a stable and near-final version of the compiler, and safe to try out in production. - -## Use React Compiler RC today {/*use-react-compiler-rc-today*/} -To install the RC: - -npm - -{`npm install --save-dev --save-exact babel-plugin-react-compiler@rc`} - - -pnpm - -{`pnpm add --save-dev --save-exact babel-plugin-react-compiler@rc`} - - -yarn - -{`yarn add --dev --exact babel-plugin-react-compiler@rc`} - - -As part of the RC, we've been making React Compiler easier to add to your projects and added optimizations to how the compiler generates memoization. React Complier now supports optional chains and array indices as dependencies. We're exploring how to infer even more dependencies like equality checks and string interpolation. These improvements ultimately result in fewer re-renders and more responsive UIs. - -We have also heard from the community that the ref-in-render validation sometimes has false positives. Since as a general philosophy we want you to be able to fully trust in the compiler's error messages and hints, we are turning it off by default for now. We will keep working to improve this validation, and we will re-enable it in a follow up release. - -You can find more details on using the Compiler in [our docs](https://react.dev/learn/react-compiler). - -## Feedback {/*feedback*/} -During the RC period, we encourage all React users to try the compiler and provide feedback in the React repo. Please [open an issue](https://github.com/facebook/react/issues) if you encounter any bugs or unexpected behavior. If you have a general question or suggestion, please post them in the [React Compiler Working Group](https://github.com/reactwg/react-compiler/discussions). - -## Backwards Compatibility {/*backwards-compatibility*/} -As noted in the Beta announcement, React Compiler is compatible with React 17 and up. If you are not yet on React 19, you can use React Compiler by specifying a minimum target in your compiler config, and adding `react-compiler-runtime` as a dependency. You can find docs on this [here](https://react.dev/learn/react-compiler#using-react-compiler-with-react-17-or-18). - -## Migrating from eslint-plugin-react-compiler to eslint-plugin-react-hooks {/*migrating-from-eslint-plugin-react-compiler-to-eslint-plugin-react-hooks*/} -If you have already installed eslint-plugin-react-compiler, you can now remove it and use `eslint-plugin-react-hooks@^6.1.1`. Many thanks to [@michaelfaith](https://bsky.app/profile/michael.faith) for contributing to this improvement! - -To install: - -npm - -{`npm install --save-dev eslint-plugin-react-hooks@^6.1.1`} - - -pnpm - -{`pnpm add --save-dev eslint-plugin-react-hooks@^6.1.1`} - - -yarn - -{`yarn add --dev eslint-plugin-react-hooks@^6.1.1`} - - -```js -// eslint.config.js -import * as reactHooks from 'eslint-plugin-react-hooks'; - -export default [ - // Flat Config (eslint 9+) - reactHooks.configs.recommended, - - // Legacy Config - reactHooks.configs['recommended-latest'] -]; -``` - -To enable the React Compiler rule, add `'react-hooks/react-compiler': 'error'` to your ESLint configuration. - -The linter does not require the compiler to be installed, so there's no risk in upgrading eslint-plugin-react-hooks. We recommend everyone upgrade today. - -## swc support (experimental) {/*swc-support-experimental*/} -React Compiler can be installed across [several build tools](/learn/react-compiler#installation) such as Babel, Vite, and Rsbuild. - -In addition to those tools, we have been collaborating with Kang Dongyoon ([@kdy1dev](https://x.com/kdy1dev)) from the [swc](https://swc.rs/) team on adding additional support for React Compiler as an swc plugin. While this work isn't done, Next.js build performance should now be considerably faster when the [React Compiler is enabled in your Next.js app](https://nextjs.org/docs/app/api-reference/config/next-config-js/reactCompiler). - -We recommend using Next.js [15.3.1](https://github.com/vercel/next.js/releases/tag/v15.3.1) or greater to get the best build performance. - -Vite users can continue to use [vite-plugin-react](https://github.com/vitejs/vite-plugin-react) to enable the compiler, by adding it as a [Babel plugin](https://react.dev/learn/react-compiler#usage-with-vite). We are also working with the [oxc](https://oxc.rs/) team to [add support for the compiler](https://github.com/oxc-project/oxc/issues/10048). Once [rolldown](https://github.com/rolldown/rolldown) is officially released and supported in Vite and oxc support is added for React Compiler, we'll update the docs with information on how to migrate. - -## Upgrading React Compiler {/*upgrading-react-compiler*/} -React Compiler works best when the auto-memoization applied is strictly for performance. Future versions of the compiler may change how memoization is applied, for example it could become more granular and precise. - -However, because product code may sometimes break the [rules of React](https://react.dev/reference/rules) in ways that aren't always statically detectable in JavaScript, changing memoization can occasionally have unexpected results. For example, a previously memoized value might be used as a dependency for a useEffect somewhere in the component tree. Changing how or whether this value is memoized can cause over or under-firing of that useEffect. While we encourage [useEffect only for synchronization](https://react.dev/learn/synchronizing-with-effects), your codebase may have useEffects that cover other use-cases such as effects that needs to only run in response to specific values changing. - -In other words, changing memoization may under rare circumstances cause unexpected behavior. For this reason, we recommend following the Rules of React and employing continuous end-to-end testing of your app so you can upgrade the compiler with confidence and identify any rules of React violations that might cause issues. - -If you don't have good test coverage, we recommend pinning the compiler to an exact version (eg `19.1.0`) rather than a SemVer range (eg `^19.1.0`). You can do this by passing the `--save-exact` (npm/pnpm) or `--exact` flags (yarn) when upgrading the compiler. You should then do any upgrades of the compiler manually, taking care to check that your app still works as expected. - -## Roadmap to Stable {/*roadmap-to-stable*/} -*This is not a final roadmap, and is subject to change.* - -After a period of final feedback from the community on the RC, we plan on a Stable Release for the compiler. - -* ✅ Experimental: Released at React Conf 2024, primarily for feedback from application developers. -* ✅ Public Beta: Available today, for feedback from library authors. -* ✅ Release Candidate (RC): React Compiler works for the majority of rule-following apps and libraries without issue. -* General Availability: After final feedback period from the community. - -Post-Stable, we plan to add more compiler optimizations and improvements. This includes both continual improvements to automatic memoization, and new optimizations altogether, with minimal to no change of product code. Each upgrade will continue to improve performance and add better handling of diverse JavaScript and React patterns. - ---- - -Thanks to [Joe Savona](https://x.com/en_JS), [Jason Bonta](https://x.com/someextent), [Jimmy Lai](https://x.com/feedthejim), and [Kang Dongyoon](https://x.com/kdy1dev) (@kdy1dev) for reviewing and editing this post. diff --git a/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md b/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md index 3b54262f88e..cdc8f353f87 100644 --- a/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md +++ b/src/content/blog/2025/04/23/react-labs-view-transitions-activity-and-more.md @@ -66,7 +66,7 @@ To opt-in to animating an element, wrap it in the new `` compone ``` -This new component lets you declaratively define "what" to animate when an animation is activated. +This new component lets you declaratively define "what" to animate when an animation is activated. You can define "when" to animate by using one of these three triggers for a View Transition: @@ -99,9 +99,9 @@ By default, these animations use the [default CSS animations for View Transition When the DOM updates due to an animation trigger—like `startTransition`, `useDeferredValue`, or a `Suspense` fallback switching to content—React will use [declarative heuristics](/reference/react/ViewTransition#viewtransition) to automatically determine which `` components to activate for the animation. The browser will then run the animation that's defined in CSS. -If you're familiar with the browser's View Transition API and want to know how React supports it, check out [How does `` Work](/reference/react/ViewTransition#how-does-viewtransition-work) in the docs. +If you're familiar with the browser's View Transition API and want to know how React supports it, check out [How does `` Work](/reference/react/ViewTransition#how-does-viewtransition-work) in the docs. -In this post, let's take a look at a few examples of how to use View Transitions. +In this post, let's take a look at a few examples of how to use View Transitions. We'll start with this app, which doesn't animate any of the following interactions: - Click a video to view the details. @@ -1294,7 +1294,7 @@ function navigate(url) { When the `url` changes, the `` and new route are rendered. Since the `` was updated inside of `startTransition`, the `` is activated for an animation. -By default, View Transitions include the browser default cross-fade animation. Adding this to our example, we now have a cross-fade whenever we navigate between pages: +By default, View Transitions include the browser default cross-fade animation. Adding this to our example, we now have a cross-fade whenever we navigate between pages: @@ -1304,7 +1304,7 @@ import Home from './Home'; import {useRouter} from './router'; export default function App() { const {url} = useRouter(); - + // Use ViewTransition to animate between pages. // No additional CSS needed by default. return ( @@ -1567,7 +1567,7 @@ import {ViewTransition} from 'react'; import { useIsNavPending } from "./router" export default function Page({ heading, children }) { const isPending = useIsNavPending(); - + return (
@@ -1771,22 +1771,22 @@ import {useState, createContext,use,useTransition,useLayoutEffect,useEffect} fro export function Router({ children }) { const [isPending, startTransition] = useTransition(); - + function navigate(url) { // Update router state in transition. startTransition(() => { go(url); }); } - - - - + + + + const [routerState, setRouterState] = useState({ pendingNav: () => {}, url: document.location.pathname, }); - + function go(url) { setRouterState({ @@ -1796,7 +1796,7 @@ export function Router({ children }) { }, }); } - + function navigateBack(url) { startTransition(() => { @@ -2457,7 +2457,7 @@ root.render( -Since our router already updates the route using `startTransition`, this one line change to add `` activates with the default cross-fade animation. +Since our router already updates the route using `startTransition`, this one line change to add `` activates with the default cross-fade animation. If you're curious how this works, see the docs for [How does `` work?](/reference/react/ViewTransition#how-does-viewtransition-work) @@ -2465,7 +2465,7 @@ If you're curious how this works, see the docs for [How does `` #### Opting out of `` animations {/*opting-out-of-viewtransition-animations*/} -In this example, we're wrapping the root of the app in `` for simplicity, but this means that all transitions in the app will be animated, which can lead to unexpected animations. +In this example, we're wrapping the root of the app in `` for simplicity, but this means that all transitions in the app will be animated, which can lead to unexpected animations. To fix, we're wrapping route children with `"none"` so each page can control its own animation: @@ -2476,7 +2476,7 @@ To fix, we're wrapping route children with `"none"` so each page can control its ``` -In practice, navigations should be done via "enter" and "exit" props, or by using Transition Types. +In practice, navigations should be done via "enter" and "exit" props, or by using Transition Types. @@ -5445,7 +5445,7 @@ import {useState, createContext, use, useTransition, useLayoutEffect, useEffect, export function Router({ children }) { const [isPending, startTransition] = useTransition(); - + function navigate(url) { startTransition(() => { // Transition type for the cause "nav forward" @@ -5472,7 +5472,7 @@ export function Router({ children }) { }, }); } - + useEffect(() => { function handlePopState() { // This should not animate because restoration has to be synchronous. @@ -6212,7 +6212,7 @@ root.render( ### Animating Suspense Boundaries {/*animating-suspense-boundaries*/} -Suspense will also activate View Transitions. +Suspense will also activate View Transitions. To animate the fallback to content, we can wrap `Suspense` with ``: @@ -6741,7 +6741,7 @@ export function Router({ children }) { }, }); } - + useEffect(() => { function handlePopState() { // This should not animate because restoration has to be synchronous. @@ -7527,7 +7527,7 @@ We can also provide custom animations using an `exit` on the fallback, and `ente Here's how we'll define `slide-down` and `slide-up` with CSS: ```css {1, 6} -::view-transition-old(.slide-down) { +::view-transition-old(.slide-down) { /* Slide the fallback down */ animation: ...; } @@ -8062,7 +8062,7 @@ export function Router({ children }) { }, }); } - + useEffect(() => { function handlePopState() { // This should not animate because restoration has to be synchronous. @@ -8953,14 +8953,14 @@ function VideoInfo({ id }) { import { useId, useState, use, useDeferredValue, ViewTransition } from "react";import { Video } from "./Videos";import Layout from "./Layout";import { fetchVideos } from "./data";import { IconSearch } from "./Icons"; function SearchList({searchText, videos}) { - // Activate with useDeferredValue ("when") + // Activate with useDeferredValue ("when") const deferredSearchText = useDeferredValue(searchText); const filteredVideos = filterVideos(videos, deferredSearchText); return (
{filteredVideos.map((video) => ( - // Animate each item in list ("what") + // Animate each item in list ("what") @@ -8977,7 +8977,7 @@ export default function Home() { const videos = use(fetchVideos()); const count = videos.length; const [searchText, setSearchText] = useState(''); - + return ( {count} Videos
}> @@ -9389,7 +9389,7 @@ export function Router({ children }) { }, }); } - + useEffect(() => { function handlePopState() { // This should not animate because restoration has to be synchronous. @@ -10269,14 +10269,14 @@ function VideoInfo({ id }) { import { useId, useState, use, useDeferredValue, ViewTransition } from "react";import { Video } from "./Videos";import Layout from "./Layout";import { fetchVideos } from "./data";import { IconSearch } from "./Icons"; function SearchList({searchText, videos}) { - // Activate with useDeferredValue ("when") + // Activate with useDeferredValue ("when") const deferredSearchText = useDeferredValue(searchText); const filteredVideos = filterVideos(videos, deferredSearchText); return (
{filteredVideos.map((video) => ( - // Animate each item in list ("what") + // Animate each item in list ("what") @@ -10293,7 +10293,7 @@ export default function Home() { const videos = use(fetchVideos()); const count = videos.length; const [searchText, setSearchText] = useState(''); - + return ( {count} Videos
}> @@ -10693,7 +10693,7 @@ export function Router({ children }) { } const [routerState, setRouterState] = useState({pendingNav: () => {}, url: document.location.pathname}); - + function go(url) { setRouterState({ url, @@ -10702,7 +10702,7 @@ export function Router({ children }) { }, }); } - + useEffect(() => { function handlePopState() { // This should not animate because restoration has to be synchronous. @@ -11507,7 +11507,7 @@ When a user navigates away from a page, it's common to stop rendering the old pa ```js {6,7} function App() { const { url } = useRouter(); - + return ( <> {url === '/' && } @@ -11524,7 +11524,7 @@ Activity allows you to keep the state around as the user changes pages, so when ```js {6-8} function App() { const { url } = useRouter(); - + return ( <> @@ -11547,7 +11547,7 @@ import { ViewTransition } from "react"; import Details from "./Details"; import export default function App() { const { url } = useRouter(); - + return ( // View Transitions know about Activity @@ -11640,7 +11640,7 @@ function VideoInfo({ id }) { import { useId, useState, use, useDeferredValue, ViewTransition } from "react";import { Video } from "./Videos";import Layout from "./Layout";import { fetchVideos } from "./data";import { IconSearch } from "./Icons"; function SearchList({searchText, videos}) { - // Activate with useDeferredValue ("when") + // Activate with useDeferredValue ("when") const deferredSearchText = useDeferredValue(searchText); const filteredVideos = filterVideos(videos, deferredSearchText); return ( @@ -11650,7 +11650,7 @@ function SearchList({searchText, videos}) { )}
{filteredVideos.map((video) => ( - // Animate each item in list ("what") + // Animate each item in list ("what") @@ -11664,7 +11664,7 @@ export default function Home() { const videos = use(fetchVideos()); const count = videos.length; const [searchText, setSearchText] = useState(''); - + return ( {count} Videos
}> @@ -12075,7 +12075,7 @@ export function Router({ children }) { }, }); } - + useEffect(() => { function handlePopState() { // This should not animate because restoration has to be synchronous. @@ -12886,7 +12886,7 @@ export default function App() { const { url } = useRouter(); const videoId = url.split("/").pop(); const videos = use(fetchVideos()); - + return ( {/* Render videos in Activity to pre-render them */} @@ -12978,7 +12978,7 @@ function VideoInfo({ id }) { import { useId, useState, use, useDeferredValue, ViewTransition } from "react";import { Video } from "./Videos";import Layout from "./Layout";import { fetchVideos } from "./data";import { IconSearch } from "./Icons"; function SearchList({searchText, videos}) { - // Activate with useDeferredValue ("when") + // Activate with useDeferredValue ("when") const deferredSearchText = useDeferredValue(searchText); const filteredVideos = filterVideos(videos, deferredSearchText); return ( @@ -12988,7 +12988,7 @@ function SearchList({searchText, videos}) { )}
{filteredVideos.map((video) => ( - // Animate each item in list ("what") + // Animate each item in list ("what") @@ -13002,7 +13002,7 @@ export default function Home() { const videos = use(fetchVideos()); const count = videos.length; const [searchText, setSearchText] = useState(''); - + return ( {count} Videos
}> @@ -13413,7 +13413,7 @@ export function Router({ children }) { }, }); } - + useEffect(() => { function handlePopState() { // This should not animate because restoration has to be synchronous. @@ -14219,13 +14219,13 @@ These are areas we're still exploring, and we'll share more as we make progress. # Features in development {/*features-in-development*/} -We're also developing features to help solve the common problems below. +We're also developing features to help solve the common problems below. -As we iterate on possible solutions, you may see some potential APIs we're testing being shared based on the PRs we are landing. Please keep in mind that as we try different ideas, we often change or remove different solutions after trying them out. +As we iterate on possible solutions, you may see some potential APIs we're testing being shared based on the PRs we are landing. Please keep in mind that as we try different ideas, we often change or remove different solutions after trying them out. -When the solutions we're working on are shared too early, it can create churn and confusion in the community. To balance being transparent and limiting confusion, we're sharing the problems we're currently developing solutions for, without sharing a particular solution we have in mind. +When the solutions we're working on are shared too early, it can create churn and confusion in the community. To balance being transparent and limiting confusion, we're sharing the problems we're currently developing solutions for, without sharing a particular solution we have in mind. -As these features progress, we'll announce them on the blog with docs included so you can try them out. +As these features progress, we'll announce them on the blog with docs included so you can try them out. ## React Performance Tracks {/*react-performance-tracks*/} @@ -14258,7 +14258,7 @@ When we released hooks, we had three motivations: - **Think in terms of function, not lifecycles**: hooks let you split one component into smaller functions based on what pieces are related (such as setting up a subscription or fetching data), rather than forcing a split based on lifecycle methods. - **Support ahead-of-time compilation**: hooks were designed to support ahead-of-time compilation with less pitfalls causing unintentional de-optimizations caused by lifecycle methods, and limitations of classes. -Since their release, hooks have been successful at *sharing code between components*. Hooks are now the favored way to share logic between components, and there are less use cases for render props and higher order components. Hooks have also been successful at supporting features like Fast Refresh that were not possible with class components. +Since their release, hooks have been successful at *sharing code between components*. Hooks are now the favored way to share logic between components, and there are less use cases for render props and higher order components. Hooks have also been successful at supporting features like Fast Refresh that were not possible with class components. ### Effects can be hard {/*effects-can-be-hard*/} @@ -14299,18 +14299,18 @@ useEffect(() => { return () => { connection.disconnect(); }; -}); // compiler inserted dependencies. +}); // compiler inserted dependencies. ``` With this code, the React Compiler can infer the dependencies for you and insert them automatically so you don't need to see or write them. With features like [the IDE extension](#compiler-ide-extension) and [`useEffectEvent`](/reference/react/useEffectEvent), we can provide a CodeLens to show you what the Compiler inserted for times you need to debug, or to optimize by removing a dependency. This helps reinforce the correct mental model for writing Effects, which can run at any time to synchronize your component or hook's state with something else. -Our hope is that automatically inserting dependencies is not only easier to write, but that it also makes them easier to understand by forcing you to think in terms of what the Effect does, and not in component lifecycles. +Our hope is that automatically inserting dependencies is not only easier to write, but that it also makes them easier to understand by forcing you to think in terms of what the Effect does, and not in component lifecycles. --- ## Compiler IDE Extension {/*compiler-ide-extension*/} -Earlier this week [we shared](/blog/2025/04/21/react-compiler-rc) the React Compiler release candidate, and we're working towards shipping the first SemVer stable version of the compiler in the coming months. +Later in 2025 [we shared](/blog/2025/10/07/react-compiler-1) the first stable release of React Compiler, and we're continuing to invest in shipping more improvements. We've also begun exploring ways to use the React Compiler to provide information that can improve understanding and debugging your code. One idea we've started exploring is a new experimental LSP-based React IDE extension powered by React Compiler, similar to the extension used in [Lauren Tan's React Conf talk](https://conf2024.react.dev/talks/5). @@ -14332,7 +14332,7 @@ Fragment refs are still being researched. We'll share more when we're closer to ## Gesture Animations {/*gesture-animations*/} -We're also researching ways to enhance View Transitions to support gesture animations such as swiping to open a menu, or scroll through a photo carousel. +We're also researching ways to enhance View Transitions to support gesture animations such as swiping to open a menu, or scroll through a photo carousel. Gestures present new challenges for a few reasons: @@ -14356,9 +14356,9 @@ Now that React 19 has shipped, we're revisiting this problem space to create a p const value = use(store); ``` -Our goal is to allow external state to be read during render without tearing, and to work seamlessly with all of the concurrent features React offers. +Our goal is to allow external state to be read during render without tearing, and to work seamlessly with all of the concurrent features React offers. -This research is still early. We'll share more, and what the new APIs will look like, when we're further along. +This research is still early. We'll share more, and what the new APIs will look like, when we're further along. --- diff --git a/src/content/blog/2025/10/01/react-19-2.md b/src/content/blog/2025/10/01/react-19-2.md index 0da15df3351..51c30f70a2a 100644 --- a/src/content/blog/2025/10/01/react-19-2.md +++ b/src/content/blog/2025/10/01/react-19-2.md @@ -98,7 +98,7 @@ function ChatRoom({ roomId, theme }) { Similar to DOM events, Effect Events always “see” the latest props and state. -**Effect Events should _not_ be declared in the dependency array**. You'll need to upgrade to `eslint-plugin-react-hooks@6.1.1` so that the linter doesn't try to insert them as dependencies. Note that Effect Events can only be declared in the same component or Hook as "their" Effect. These restrictions are verified by the linter. +**Effect Events should _not_ be declared in the dependency array**. You'll need to upgrade to `eslint-plugin-react-hooks@latest` so that the linter doesn't try to insert them as dependencies. Note that Effect Events can only be declared in the same component or Hook as "their" Effect. These restrictions are verified by the linter. @@ -289,7 +289,7 @@ This is because Node Streams are much faster than Web Streams in Node, and Web S ### `eslint-plugin-react-hooks` v6 {/*eslint-plugin-react-hooks*/} -We also published `eslint-plugin-react-hooks@6.1.1` with flat config by default in the `recommended` preset, and opt-in for new React Compiler powered rules. +We also published `eslint-plugin-react-hooks@latest` with flat config by default in the `recommended` preset, and opt-in for new React Compiler powered rules. To continue using the legacy config, you can change to `recommended-legacy`: @@ -298,7 +298,7 @@ To continue using the legacy config, you can change to `recommended-legacy`: + extends: ['plugin:react-hooks/recommended-legacy'] ``` -For a full list of compiler enabled rules, [check out the linter docs](/reference/eslint-plugin-react-hooks#additional-rules). +For a full list of compiler enabled rules, [check out the linter docs](/reference/eslint-plugin-react-hooks#recommended). Check out the `eslint-plugin-react-hooks` [changelog for a full list of changes](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/CHANGELOG.md#610). diff --git a/src/content/blog/2025/10/07/react-compiler-1.md b/src/content/blog/2025/10/07/react-compiler-1.md new file mode 100644 index 00000000000..5474c50d3f2 --- /dev/null +++ b/src/content/blog/2025/10/07/react-compiler-1.md @@ -0,0 +1,194 @@ +--- +title: "React Compiler v1.0" +author: Lauren Tan, Joe Savona, and Mofei Zhang +date: 2025/10/07 +description: We are releasing the compiler's first stable release today. + +--- + +Oct 7, 2025 by [Lauren Tan](https://x.com/potetotes), [Joe Savona](https://x.com/en_JS), and [Mofei Zhang](https://x.com/zmofei). + +--- + + + +The React team is excited to share new updates: + + + +1. React Compiler 1.0 is available today. +2. Compiler-powered lint rules ship in `eslint-plugin-react-hooks`'s `recommended` and `recommended-latest` preset. +3. We've published an incremental adoption guide, and partnered with Expo, Vite, and Next.js so new apps can start with the compiler enabled. + +--- + +We are releasing the compiler's first stable release today. React Compiler works on both React and React Native, and automatically optimizes components and hooks without requiring rewrites. The compiler has been battle tested on major apps at Meta and is fully production-ready. + +[React Compiler](/learn/react-compiler) is a build-time tool that optimizes your React app through automatic memoization. Last year, we published React Compiler's [first beta](/blog/2024/10/21/react-compiler-beta-release) and received lots of great feedback and contributions. We're excited about the wins we've seen from folks adopting the compiler (see case studies from [Sanity Studio](https://github.com/reactwg/react-compiler/discussions/33) and [Wakelet](https://github.com/reactwg/react-compiler/discussions/52)) and are excited to bring the compiler to more users in the React community. + +This release is the culmination of a huge and complex engineering effort spanning almost a decade. The React team's first exploration into compilers started with [Prepack](https://github.com/facebookarchive/prepack) in 2017. While this project was eventually shut down, there were many learnings that informed the team on the design of Hooks, which were designed with a future compiler in mind. In 2021, [Xuan Huang](https://x.com/Huxpro) demoed the [first iteration](https://www.youtube.com/watch?v=lGEMwh32soc) of a new take on React Compiler. + +Although this first version of the new React Compiler was eventually rewritten, the first prototype gave us increased confidence that this was a tractable problem, and the learnings that an alternative compiler architecture could precisely give us the memoization characteristics we wanted. [Joe Savona](https://x.com/en_JS), [Sathya Gunasekaran](https://x.com/_gsathya), [Mofei Zhang](https://x.com/zmofei), and [Lauren Tan](https://x.com/potetotes) worked through our first rewrite, moving the compiler's architecture into a Control Flow Graph (CFG) based High-Level Intermediate Representation (HIR). This paved the way for much more precise analysis and even type inference within React Compiler. Since then, many significant portions of the compiler have been rewritten, with each rewrite informed by our learnings from the previous attempt. And we have received significant help and contributions from many members of the [React team](/community/team) along the way. + +This stable release is our first of many. The compiler will continue to evolve and improve, and we expect to see it become a new foundation and era for the next decade and more of React. + +You can jump straight to the [quickstart](/learn/react-compiler), or read on for the highlights from React Conf 2025. + + + +#### How does React Compiler work? {/*how-does-react-compiler-work*/} + +React Compiler is an optimizing compiler that optimizes components and hooks through automatic memoization. While it is implemented as a Babel plugin currently, the compiler is largely decoupled from Babel and lowers the Abstract Syntax Tree (AST) provided by Babel into its own novel HIR, and through multiple compiler passes, carefully understands data-flow and mutability of your React code. This allows the compiler to granularly memoize values used in rendering, including the ability to memoize conditionally, which is not possible through manual memoization. + +```js {8} +import { use } from 'react'; + +export default function ThemeProvider(props) { + if (!props.children) { + return null; + } + // The compiler can still memoize code after a conditional return + const theme = mergeTheme(props.theme, use(ThemeContext)); + return ( + + {props.children} + + ); +} +``` +_See this example in the [React Compiler Playground](https://playground.react.dev/#N4Igzg9grgTgxgUxALhASwLYAcIwC4AEwBUYCBAvgQGYwQYEDkMCAhnHowNwA6AdvwQAPHPgIATBNVZQANoWpQ+HNBD4EAKgAsEGBAAU6ANzSSYACix0sYAJRF+BAmmoFzAQisQbAOjha0WXEWPntgRycCFjxYdT45WV51Sgi4NTBCPB09AgBeAj0YAHMEbV0ES2swHyzygBoSMnMyvQBhNTxhPFtbJKdo2LcIpwAeFoR2vk6hQiNWWSgEXOBavQoAPmHI4C9ff0DghD4KLZGAenHJ6bxN5N7+ChA6kDS+ajQilHRsXEyATyw5GI+gWRTQfAA8lg8Ko+GBKDQ6AxGAAjVgohCyAC0WFB4KxLHYeCxaWwgQQMDO4jQGW4-H45nCyTOZ1JWECrBhagAshBJMgCDwQPNZEKHgQwJyae8EPCQVAwZDobC7FwnuAtBAAO4ASSmFL48zAKGksjIFCAA)_ + +In addition to automatic memoization, React Compiler also has validation passes that run on your React code. These passes encode the [Rules of React](/reference/rules), and uses the compiler's understanding of data-flow and mutability to provide diagnostics where the Rules of React are broken. These diagnostics often expose latent bugs hiding in React code, and are primarily surfaced through `eslint-plugin-react-hooks`. + +To learn more about how the compiler optimizes your code, visit the [Playground](https://playground.react.dev). + + + +## Use React Compiler Today {/*use-react-compiler-today*/} +To install the compiler: + +npm + +{`npm install --save-dev --save-exact babel-plugin-react-compiler@latest`} + + +pnpm + +{`pnpm add --save-dev --save-exact babel-plugin-react-compiler@latest`} + + +yarn + +{`yarn add --dev --exact babel-plugin-react-compiler@latest`} + + +As part of the stable release, we've been making React Compiler easier to add to your projects and added optimizations to how the compiler generates memoization. React Compiler now supports optional chains and array indices as dependencies. These improvements ultimately result in fewer re-renders and more responsive UIs, while letting you keep writing idiomatic declarative code. + +You can find more details on using the Compiler in [our docs](/learn/react-compiler). + +## What we're seeing in production {/*react-compiler-at-meta*/} +[The compiler has already shipped in apps like Meta Quest Store](https://youtu.be/lyEKhv8-3n0?t=3002). We've seen initial loads and cross-page navigations improve by up to 12%, while certain interactions are more than 2.5× faster. Memory usage stays neutral even with these wins. Although your mileage may vary, we recommend experimenting with the compiler in your app to see similar performance gains. + +## Backwards Compatibility {/*backwards-compatibility*/} +As noted in the Beta announcement, React Compiler is compatible with React 17 and up. If you are not yet on React 19, you can use React Compiler by specifying a minimum target in your compiler config, and adding `react-compiler-runtime` as a dependency. You can find docs on this [here](/reference/react-compiler/target#targeting-react-17-or-18). + +## Enforce the Rules of React with compiler-powered linting {/*migrating-from-eslint-plugin-react-compiler-to-eslint-plugin-react-hooks*/} +React Compiler includes an ESLint rule that helps identify code that breaks the [Rules of React](/reference/rules). The linter does not require the compiler to be installed, so there's no risk in upgrading eslint-plugin-react-hooks. We recommend everyone upgrade today. + +If you have already installed `eslint-plugin-react-compiler`, you can now remove it and use `eslint-plugin-react-hooks@latest`. Many thanks to [@michaelfaith](https://bsky.app/profile/michael.faith) for contributing to this improvement! + +To install: + +npm + +{`npm install --save-dev eslint-plugin-react-hooks@latest`} + + +pnpm + +{`pnpm add --save-dev eslint-plugin-react-hooks@latest`} + + +yarn + +{`yarn add --dev eslint-plugin-react-hooks@latest`} + + +```js {6} +// eslint.config.js (Flat Config) +import reactHooks from 'eslint-plugin-react-hooks'; +import { defineConfig } from 'eslint/config'; + +export default defineConfig([ + reactHooks.configs.flat.recommended, +]); +``` + +```js {3} +// eslintrc.json (Legacy Config) +{ + "extends": ["plugin:react-hooks/recommended"], + // ... +} +``` + +To enable React Compiler rules, we recommend using the `recommended` preset. You can also check out the [README](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md) for more instructions. Here are a few examples we featured at React Conf: + +- Catching `setState` patterns that cause render loops with [`set-state-in-render`](/reference/eslint-plugin-react-hooks/lints/set-state-in-render). +- Flagging expensive work inside effects via [`set-state-in-effect`](/reference/eslint-plugin-react-hooks/lints/set-state-in-effect). +- Preventing unsafe ref access during render with [`refs`](/reference/eslint-plugin-react-hooks/lints/refs). + +## What should I do about useMemo, useCallback, and React.memo? {/*what-should-i-do-about-usememo-usecallback-and-reactmemo*/} +By default, React Compiler will memoize your code based on its analysis and heuristics. In most cases, this memoization will be as precise, or moreso, than what you may have written — and as noted above, the compiler can memoize even in cases where `useMemo`/`useCallback` cannot be used, such as after an early return. + +However, in some cases developers may need more control over memoization. The `useMemo` and `useCallback` hooks can continue to be used with React Compiler as an escape hatch to provide control over which values are memoized. A common use-case for this is if a memoized value is used as an effect dependency, in order to ensure that an effect does not fire repeatedly even when its dependencies do not meaningfully change. + +For new code, we recommend relying on the compiler for memoization and using `useMemo`/`useCallback` where needed to achieve precise control. + +For existing code, we recommend either leaving existing memoization in place (removing it can change compilation output) or carefully testing before removing the memoization. + +## New apps should use React Compiler {/*new-apps-should-use-react-compiler*/} +We have partnered with the Expo, Vite, and Next.js teams to add the compiler to the new app experience. + +[Expo SDK 54](https://docs.expo.dev/guides/react-compiler/) and up has the compiler enabled by default, so new apps will automatically be able to take advantage of the compiler from the start. + + +{`npx create-expo-app@latest`} + + +[Vite](https://vite.dev/guide/) and [Next.js](https://nextjs.org/docs/app/api-reference/cli/create-next-app) users can choose the compiler enabled templates in `create-vite` and `create-next-app`. + + +{`npm create vite@latest`} + + +
+ + +{`npx create-next-app@latest`} + + +## Adopt React Compiler incrementally {/*adopt-react-compiler-incrementally*/} +If you're maintaining an existing application, you can roll out the compiler at your own pace. We published a step-by-step [incremental adoption guide](/learn/react-compiler/incremental-adoption) that covers gating strategies, compatibility checks, and rollout tooling so you can enable the compiler with confidence. + +## swc support (experimental) {/*swc-support-experimental*/} +React Compiler can be installed across [several build tools](/learn/react-compiler#installation) such as Babel, Vite, and Rsbuild. + +In addition to those tools, we have been collaborating with Kang Dongyoon ([@kdy1dev](https://x.com/kdy1dev)) from the [swc](https://swc.rs/) team on adding additional support for React Compiler as an swc plugin. While this work isn't done, Next.js build performance should now be considerably faster when the [React Compiler is enabled in your Next.js app](https://nextjs.org/docs/app/api-reference/config/next-config-js/reactCompiler). + +We recommend using Next.js [15.3.1](https://github.com/vercel/next.js/releases/tag/v15.3.1) or greater to get the best build performance. + +Vite users can continue to use [vite-plugin-react](https://github.com/vitejs/vite-plugin-react) to enable the compiler, by adding it as a [Babel plugin](/learn/react-compiler/installation#vite). We are also working with the [oxc](https://oxc.rs/) team to [add support for the compiler](https://github.com/oxc-project/oxc/issues/10048). Once [rolldown](https://github.com/rolldown/rolldown) is officially released and supported in Vite and oxc support is added for React Compiler, we'll update the docs with information on how to migrate. + +## Upgrading React Compiler {/*upgrading-react-compiler*/} +React Compiler works best when the auto-memoization applied is strictly for performance. Future versions of the compiler may change how memoization is applied, for example it could become more granular and precise. + +However, because product code may sometimes break the [rules of React](/reference/rules) in ways that aren't always statically detectable in JavaScript, changing memoization can occasionally have unexpected results. For example, a previously memoized value might be used as a dependency for a `useEffect` somewhere in the component tree. Changing how or whether this value is memoized can cause over or under-firing of that `useEffect`. While we encourage [useEffect only for synchronization](/learn/synchronizing-with-effects), your codebase may have `useEffect`s that cover other use cases, such as effects that needs to only run in response to specific values changing. + +In other words, changing memoization may under rare circumstances cause unexpected behavior. For this reason, we recommend following the Rules of React and employing continuous end-to-end testing of your app so you can upgrade the compiler with confidence and identify any rules of React violations that might cause issues. + +If you don't have good test coverage, we recommend pinning the compiler to an exact version (eg `1.0.0`) rather than a SemVer range (eg `^1.0.0`). You can do this by passing the `--save-exact` (npm/pnpm) or `--exact` flags (yarn) when upgrading the compiler. You should then do any upgrades of the compiler manually, taking care to check that your app still works as expected. + +--- + +Thanks to [Jason Bonta](https://x.com/someextent), [Jimmy Lai](https://x.com/feedthejim), [Kang Dongyoon](https://x.com/kdy1dev) (@kdy1dev), and [Dan Abramov](https://bsky.app/profile/danabra.mov) for reviewing and editing this post. diff --git a/src/content/blog/index.md b/src/content/blog/index.md index 91f18493777..a3054227590 100644 --- a/src/content/blog/index.md +++ b/src/content/blog/index.md @@ -12,6 +12,12 @@ You can also follow the [@react.dev](https://bsky.app/profile/react.dev) account
+ + +We're releasing the compiler's first stable release today, plus linting and tooling improvements to make adoption easier. + + + Today, we're announcing our plans to create the React Foundation and a new technical governance structure ... @@ -30,12 +36,6 @@ In React Labs posts, we write about projects in active research and development. - - -We are releasing the compiler's first Release Candidate (RC) today. - - - Today, we’re deprecating Create React App for new apps, and encouraging existing apps to migrate to a framework, or to migrate to a build tool like Vite, Parcel, or RSBuild. We’re also providing docs for when a framework isn’t a good fit for your project, you want to build your own framework, or you just want to learn how React works by building a React app from scratch ... diff --git a/src/content/learn/react-compiler/installation.md b/src/content/learn/react-compiler/installation.md index 7987e12640b..92cf0b74e53 100644 --- a/src/content/learn/react-compiler/installation.md +++ b/src/content/learn/react-compiler/installation.md @@ -18,28 +18,24 @@ This guide will help you install and configure React Compiler in your React appl React Compiler is designed to work best with React 19, but it also supports React 17 and 18. Learn more about [React version compatibility](/reference/react-compiler/target). - -React Compiler is currently in RC. Install it using the `@rc` tag to get the latest release candidate version. - - ## Installation {/*installation*/} Install React Compiler as a `devDependency`: -npm install -D babel-plugin-react-compiler@rc +npm install -D babel-plugin-react-compiler@latest Or with Yarn: -yarn add -D babel-plugin-react-compiler@rc +yarn add -D babel-plugin-react-compiler@latest Or with pnpm: -pnpm install -D babel-plugin-react-compiler@rc +pnpm install -D babel-plugin-react-compiler@latest ## Basic Setup {/*basic-setup*/} @@ -173,7 +169,7 @@ React Compiler includes an ESLint rule that helps identify code that can't be op Install the ESLint plugin: -npm install -D eslint-plugin-react-hooks@^6.1.1 +npm install -D eslint-plugin-react-hooks@latest If you haven't already configured eslint-plugin-react-hooks, follow the [installation instructions in the readme](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md#installation). The compiler rules are available in the `recommended-latest` preset. diff --git a/src/content/learn/react-compiler/introduction.md b/src/content/learn/react-compiler/introduction.md index 9957b8227e1..ff5d6eae483 100644 --- a/src/content/learn/react-compiler/introduction.md +++ b/src/content/learn/react-compiler/introduction.md @@ -16,10 +16,6 @@ React Compiler is a new build-time tool that automatically optimizes your React - -React Compiler is currently in Release Candidate (RC). We now recommend everyone to try the compiler and provide feedback. The latest RC release can be found with the `@rc` tag. - - ## What does React Compiler do? {/*what-does-react-compiler-do*/} React Compiler automatically optimizes your React application at build time. React is often fast enough without optimization, but sometimes you need to manually memoize components and values to keep your app responsive. This manual memoization is tedious, easy to get wrong, and adds extra code to maintain. React Compiler does this optimization automatically for you, freeing you from this mental burden so you can focus on building features. @@ -157,7 +153,7 @@ We encourage everyone to start using React Compiler. While the compiler is still ### Is it safe to use? {/*is-it-safe-to-use*/} -React Compiler is now in RC and has been tested extensively in production. 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 [Rules of React](/reference/rules). +React Compiler is now stable and has been tested extensively in production. 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 [Rules of React](/reference/rules). ## What build tools are supported? {/*what-build-tools-are-supported*/} @@ -169,9 +165,13 @@ Next.js users can enable the swc-invoked React Compiler by using [v15.3.1](https ## What should I do about useMemo, useCallback, and React.memo? {/*what-should-i-do-about-usememo-usecallback-and-reactmemo*/} -React Compiler adds automatic memoization more precisely and granularly than is possible with [`useMemo`](/reference/react/useMemo), [`useCallback`](/reference/react/useCallback), and [`React.memo`](/reference/react/memo). If you choose to keep manual memoization, React Compiler will analyze them and determine if your manual memoization matches its automatically inferred memoization. If there isn't a match, the compiler will choose to bail out of optimizing that component. +By default, React Compiler will memoize your code based on its analysis and heuristics. In most cases, this memoization will be as precise, or moreso, than what you may have written. + +However, in some cases developers may need more control over memoization. The `useMemo` and `useCallback` hooks can continue to be used with React Compiler as an escape hatch to provide control over which values are memoized. A common use-case for this is if a memoized value is used as an effect dependency, in order to ensure that an effect does not fire repeatedly even when its dependencies do not meaningfully change. + +For new code, we recommend relying on the compiler for memoization and using `useMemo`/`useCallback` where needed to achieve precise control. -This is done out of caution as a common anti-pattern with manual memoization is using it for correctness. This means your app depends on specific values being memoized to work properly. For example, in order to prevent an infinite loop, you may have memoized some values to stop a `useEffect` call from firing. This breaks the Rules of React, but since it can potentially be dangerous for the compiler to automatically remove manual memoization, the compiler will just bail out instead. You should manually remove your handwritten memoization and verify that your app still works as expected. +For existing code, we recommend either leaving existing memoization in place (removing it can change compilation output) or carefully testing before removing the memoization. ## Try React Compiler {/*try-react-compiler*/} diff --git a/src/content/reference/eslint-plugin-react-hooks/index.md b/src/content/reference/eslint-plugin-react-hooks/index.md index 34dbdc632c9..b3a16bc3702 100644 --- a/src/content/reference/eslint-plugin-react-hooks/index.md +++ b/src/content/reference/eslint-plugin-react-hooks/index.md @@ -19,15 +19,10 @@ What this means for linting, is that you don’t need to fix all violations imme ## Recommended Rules {/*recommended*/} -These rules are included in the `recommended` preset `eslint-plugin-react-hooks`: +These rules are included in the `recommended` preset in `eslint-plugin-react-hooks`: * [`exhaustive-deps`](/reference/eslint-plugin-react-hooks/lints/exhaustive-deps) - Validates that dependency arrays for React hooks contain all necessary dependencies * [`rules-of-hooks`](/reference/eslint-plugin-react-hooks/lints/rules-of-hooks) - Validates that components and hooks follow the Rules of Hooks - -## Additional Rules {/*additional-rules*/} - -Starting in version 6.0, these rules are available to opt-in: - * [`component-hook-factories`](/reference/eslint-plugin-react-hooks/lints/component-hook-factories) - Validates higher order functions defining nested components or hooks * [`config`](/reference/eslint-plugin-react-hooks/lints/config) - Validates the compiler configuration options * [`error-boundaries`](/reference/eslint-plugin-react-hooks/lints/error-boundaries) - Validates usage of Error Boundaries instead of try/catch for child errors diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md b/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md index 49d6b6d43da..537903abdd0 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md @@ -8,12 +8,6 @@ Validates against higher order functions defining nested components or hooks. Co - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Defining components or hooks inside other functions creates new instances on every call. React treats each as a completely different component, destroying and recreating the entire component tree, losing all state, and causing performance problems. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/config.md b/src/content/reference/eslint-plugin-react-hooks/lints/config.md index 98bc8b27855..719e08412e5 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/config.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/config.md @@ -1,6 +1,5 @@ --- title: config -version: rc --- @@ -9,12 +8,6 @@ Validates the compiler [configuration options](/reference/react-compiler/configu - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} React Compiler accepts various [configuration options](/reference/react-compiler/configuration) to control its behavior. This rule validates that your configuration uses correct option names and value types, preventing silent failures from typos or incorrect settings. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/error-boundaries.md b/src/content/reference/eslint-plugin-react-hooks/lints/error-boundaries.md index c9430ea36b2..830098e5be3 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/error-boundaries.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/error-boundaries.md @@ -1,6 +1,5 @@ --- title: error-boundaries -version: rc --- @@ -9,12 +8,6 @@ Validates usage of Error Boundaries instead of try/catch for errors in child com - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Try/catch blocks can't catch errors that happen during React's rendering process. Errors thrown in rendering methods or hooks bubble up through the component tree. Only [Error Boundaries](/reference/react/Component#catching-rendering-errors-with-an-error-boundary) can catch these errors. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/gating.md b/src/content/reference/eslint-plugin-react-hooks/lints/gating.md index 62b98df0898..3bd662a86e1 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/gating.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/gating.md @@ -1,6 +1,5 @@ --- title: gating -version: rc --- @@ -9,12 +8,6 @@ Validates configuration of [gating mode](/reference/react-compiler/gating). - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Gating mode lets you gradually adopt React Compiler by marking specific components for optimization. This rule ensures your gating configuration is valid so the compiler knows which components to process. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/globals.md b/src/content/reference/eslint-plugin-react-hooks/lints/globals.md index ea429404a86..fe0cbe0080f 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/globals.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/globals.md @@ -1,6 +1,5 @@ --- title: globals -version: rc --- @@ -9,12 +8,6 @@ Validates against assignment/mutation of globals during render, part of ensuring - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Global variables exist outside React's control. When you modify them during render, you break React's assumption that rendering is pure. This can cause components to behave differently in development vs production, break Fast Refresh, and make your app impossible to optimize with features like React Compiler. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/immutability.md b/src/content/reference/eslint-plugin-react-hooks/lints/immutability.md index 33498ebe8c7..2314cde0649 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/immutability.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/immutability.md @@ -1,6 +1,5 @@ --- title: immutability -version: rc --- @@ -9,12 +8,6 @@ Validates against mutating props, state, and other values that [are immutable](/ - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} A component’s props and state are immutable snapshots. Never mutate them directly. Instead, pass new props down, and use the setter function from `useState`. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/incompatible-library.md b/src/content/reference/eslint-plugin-react-hooks/lints/incompatible-library.md index b041d02c5a5..e057e1978d9 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/incompatible-library.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/incompatible-library.md @@ -1,6 +1,5 @@ --- title: incompatible-library -version: rc --- @@ -11,12 +10,6 @@ Validates against usage of libraries which are incompatible with memoization (ma -This rule is available in `eslint-plugin-react-hooks` v6. - - - - - These libraries were designed before React's memoization rules were fully documented. They made the correct choices at the time to optimize for ergonomic ways to keep components just the right amount of reactive as app state changes. While these legacy patterns worked, we have since discovered that it's incompatible with React's programming model. We will continue working with library authors to migrate these libraries to use patterns that follow the Rules of React. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization.md b/src/content/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization.md index 5efc2f82d7a..93b582b1e16 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization.md @@ -1,6 +1,5 @@ --- title: preserve-manual-memoization -version: rc --- @@ -9,12 +8,6 @@ Validates that existing manual memoization is preserved by the compiler. React C - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} React Compiler preserves your existing `useMemo`, `useCallback`, and `React.memo` calls. If you've manually memoized something, the compiler assumes you had a good reason and won't remove it. However, incomplete dependencies prevent the compiler from understanding your code's data flow and applying further optimizations. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/purity.md b/src/content/reference/eslint-plugin-react-hooks/lints/purity.md index 74c1327597a..af8aacc612d 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/purity.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/purity.md @@ -1,6 +1,5 @@ --- title: purity -version: rc --- @@ -9,12 +8,6 @@ Validates that [components/hooks are pure](/reference/rules/components-and-hooks - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} React components must be pure functions - given the same props, they should always return the same JSX. When components use functions like `Math.random()` or `Date.now()` during render, they produce different output each time, breaking React's assumptions and causing bugs like hydration mismatches, incorrect memoization, and unpredictable behavior. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/refs.md b/src/content/reference/eslint-plugin-react-hooks/lints/refs.md index d8fe222e825..3108fdd89da 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/refs.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/refs.md @@ -1,6 +1,5 @@ --- title: refs -version: rc --- @@ -9,12 +8,6 @@ Validates correct usage of refs, not reading/writing during render. See the "pit - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Refs hold values that aren't used for rendering. Unlike state, changing a ref doesn't trigger a re-render. Reading or writing `ref.current` during render breaks React's expectations. Refs might not be initialized when you try to read them, and their values can be stale or inconsistent. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-effect.md b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-effect.md index 33491549993..64fa5c655a9 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-effect.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-effect.md @@ -1,6 +1,5 @@ --- title: set-state-in-effect -version: rc --- @@ -9,12 +8,6 @@ Validates against calling setState synchronously in an effect, which can lead to - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Setting state immediately inside an effect forces React to restart the entire render cycle. When you update state in an effect, React must re-render your component, apply changes to the DOM, and then run effects again. This creates an extra render pass that could have been avoided by transforming data directly during render or deriving state from props. Transform data at the top level of your component instead. This code will naturally re-run when props or state change without triggering additional render cycles. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md index a88de100663..7517d5f9286 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md @@ -1,6 +1,5 @@ --- title: set-state-in-render -version: rc --- @@ -9,12 +8,6 @@ Validates against unconditionally setting state during render, which can trigger - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Calling `setState` during render unconditionally triggers another render before the current one finishes. This creates an infinite loop that crashes your app. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/static-components.md b/src/content/reference/eslint-plugin-react-hooks/lints/static-components.md index b403cc0b6af..bd52f07037a 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/static-components.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/static-components.md @@ -1,6 +1,5 @@ --- title: static-components -version: rc --- @@ -9,12 +8,6 @@ Validates that components are static, not recreated every render. Components tha - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} Components defined inside other components are recreated on every render. React sees each as a brand new component type, unmounting the old one and mounting the new one, destroying all state and DOM nodes in the process. @@ -36,10 +29,10 @@ function Parent() { // ❌ Dynamic component creation function Parent({type}) { - const Component = type === 'button' + const Component = type === 'button' ? () => : () =>
Text
; - + return ; } ``` @@ -54,10 +47,10 @@ const ButtonComponent = () => ; const TextComponent = () =>
Text
; function Parent({type}) { - const Component = type === 'button' + const Component = type === 'button' ? ButtonComponent // Reference existing component : TextComponent; - + return ; } ``` @@ -72,7 +65,7 @@ You might define components inside to access local state: // ❌ Wrong: Inner component to access parent state function Parent() { const [theme, setTheme] = useState('light'); - + function ThemedButton() { // Recreated every render! return ( ); } - + return ; } ``` diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/unsupported-syntax.md b/src/content/reference/eslint-plugin-react-hooks/lints/unsupported-syntax.md index b6055449a1d..a3eefcdb24f 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/unsupported-syntax.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/unsupported-syntax.md @@ -1,6 +1,5 @@ --- title: unsupported-syntax -version: rc --- @@ -9,12 +8,6 @@ Validates against syntax that React Compiler does not support. If you need to, y - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} React Compiler needs to statically analyze your code to apply optimizations. Features like `eval` and `with` make it impossible to statically understand what the code does at compile time, so the compiler can't optimize components that use them. diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md b/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md index faa8c42d12b..a5a77e5f6e8 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md @@ -1,6 +1,5 @@ --- title: use-memo -version: rc --- @@ -9,12 +8,6 @@ Validates that the `useMemo` hook is used with a return value. See [`useMemo` do - - -This rule is available in `eslint-plugin-react-hooks` v6. - - - ## Rule Details {/*rule-details*/} `useMemo` is for computing and caching expensive values, not for side effects. Without a return value, `useMemo` returns `undefined`, which defeats its purpose and likely indicates you're using the wrong hook. diff --git a/src/content/reference/react-compiler/compiling-libraries.md b/src/content/reference/react-compiler/compiling-libraries.md index f09ffcb725f..ec0a7581eae 100644 --- a/src/content/reference/react-compiler/compiling-libraries.md +++ b/src/content/reference/react-compiler/compiling-libraries.md @@ -21,7 +21,7 @@ As a library author, you can compile your library code before publishing to npm. Add React Compiler to your library's build process: -npm install -D babel-plugin-react-compiler@rc +npm install -D babel-plugin-react-compiler@latest Configure your build tool to compile your library. For example, with Babel: @@ -45,13 +45,13 @@ If your library supports React versions below 19, you'll need additional configu We recommend installing react-compiler-runtime as a direct dependency: -npm install react-compiler-runtime@rc +npm install react-compiler-runtime@latest ```json { "dependencies": { - "react-compiler-runtime": "^19.1.0-rc.2" + "react-compiler-runtime": "^1.0.0" }, "peerDependencies": { "react": "^17.0.0 || ^18.0.0 || ^19.0.0" diff --git a/src/content/reference/react-compiler/configuration.md b/src/content/reference/react-compiler/configuration.md index f38f1afc0a4..ec9b27e6f57 100644 --- a/src/content/reference/react-compiler/configuration.md +++ b/src/content/reference/react-compiler/configuration.md @@ -130,7 +130,7 @@ module.exports = { Older React versions need the runtime package and target configuration: ```bash -npm install react-compiler-runtime@rc +npm install react-compiler-runtime@latest ``` ```js diff --git a/src/content/reference/react-compiler/target.md b/src/content/reference/react-compiler/target.md index 381748513d9..8ccc4a6b125 100644 --- a/src/content/reference/react-compiler/target.md +++ b/src/content/reference/react-compiler/target.md @@ -45,7 +45,7 @@ Configures the React version compatibility for the compiled output. - Always use string values, not numbers (e.g., `'17'` not `17`) - Don't include patch versions (e.g., use `'18'` not `'18.2.0'`) - React 19 includes built-in compiler runtime APIs -- React 17 and 18 require installing `react-compiler-runtime@rc` +- React 17 and 18 require installing `react-compiler-runtime@latest` --- @@ -75,7 +75,7 @@ For React 17 and React 18 projects, you need two steps: 1. Install the runtime package: ```bash -npm install react-compiler-runtime@rc +npm install react-compiler-runtime@latest ``` 2. Configure the target: @@ -114,7 +114,7 @@ If you see errors like "Cannot find module 'react/compiler-runtime'": 2. If using React 17 or 18, install the runtime: ```bash - npm install react-compiler-runtime@rc + npm install react-compiler-runtime@latest ``` 3. Ensure your target matches your React version: @@ -130,7 +130,7 @@ Ensure the runtime package is: 1. Installed in your project (not globally) 2. Listed in your `package.json` dependencies -3. The correct version (`@rc` tag) +3. The correct version (`@latest` tag) 4. Not in `devDependencies` (it's needed at runtime) ### Checking compiled output {/*checking-output*/} diff --git a/src/content/versions.md b/src/content/versions.md index 780c13eb0bd..abb32cec456 100644 --- a/src/content/versions.md +++ b/src/content/versions.md @@ -41,7 +41,7 @@ For versions older than React 15, see [15.react.dev](https://15.react.dev). - [React v19](/blog/2024/12/05/react-19) - [React 19 Upgrade Guide](/blog/2024/04/25/react-19-upgrade-guide) - [React Compiler Beta Release](/blog/2024/10/21/react-compiler-beta-release) -- [React Compiler RC](/blog/2025/04/21/react-compiler-rc) +- [React Compiler v1.0](/blog/2025/10/07/react-compiler-1) - [React 19.2](/blog/2025/10/01/react-19-2) **Talks** @@ -299,7 +299,7 @@ For versions older than React 15, see [15.react.dev](https://15.react.dev). React was open-sourced on May 29, 2013. The initial commit is: [`75897c`: Initial public release](https://github.com/facebook/react/commit/75897c2dcd1dd3a6ca46284dd37e13d22b4b16b4) -See the first blog post: [Why did we build React?](https://legacy.reactjs.org/blog/2013/06/05/why-react.html) +See the first blog post: [Why did we build React?](https://legacy.reactjs.org/blog/2013/06/05/why-react.html) React was open sourced at Facebook Seattle in 2013: diff --git a/src/sidebarBlog.json b/src/sidebarBlog.json index dad2c44c46f..be88c3b4a44 100644 --- a/src/sidebarBlog.json +++ b/src/sidebarBlog.json @@ -11,6 +11,13 @@ "path": "/blog", "skipBreadcrumb": true, "routes": [ + { + "title": "React Compiler v1.0", + "titleForHomepage": "React Compiler v1.0", + "icon": "blog", + "date": "October 8, 2025", + "path": "/blog/2025/10/07/react-compiler-1" + }, { "title": "Introducing the React Foundation", "titleForHomepage": "Introducing the React Foundation", @@ -25,13 +32,6 @@ "date": "April 23, 2025", "path": "/blog/2025/04/23/react-labs-view-transitions-activity-and-more" }, - { - "title": "React Compiler RC", - "titleForHomepage": "React Compiler RC", - "icon": "blog", - "date": "April 21, 2025", - "path": "/blog/2025/04/21/react-compiler-rc" - }, { "title": "Sunsetting Create React App", "titleForHomepage": "Sunsetting Create React App", diff --git a/src/sidebarReference.json b/src/sidebarReference.json index 74acac4d41d..622fa687429 100644 --- a/src/sidebarReference.json +++ b/src/sidebarReference.json @@ -422,80 +422,65 @@ }, { "title": "component-hook-factories", - "path": "/reference/eslint-plugin-react-hooks/lints/component-hook-factories", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/component-hook-factories" }, { "title": "config", - "path": "/reference/eslint-plugin-react-hooks/lints/config", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/config" }, { "title": "error-boundaries", - "path": "/reference/eslint-plugin-react-hooks/lints/error-boundaries", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/error-boundaries" }, { "title": "gating", - "path": "/reference/eslint-plugin-react-hooks/lints/gating", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/gating" }, { "title": "globals", - "path": "/reference/eslint-plugin-react-hooks/lints/globals", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/globals" }, { "title": "immutability", - "path": "/reference/eslint-plugin-react-hooks/lints/immutability", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/immutability" }, { "title": "incompatible-library", - "path": "/reference/eslint-plugin-react-hooks/lints/incompatible-library", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/incompatible-library" }, { "title": "preserve-manual-memoization", - "path": "/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization" }, { "title": "purity", - "path": "/reference/eslint-plugin-react-hooks/lints/purity", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/purity" }, { "title": "refs", - "path": "/reference/eslint-plugin-react-hooks/lints/refs", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/refs" }, { "title": "set-state-in-effect", - "path": "/reference/eslint-plugin-react-hooks/lints/set-state-in-effect", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/set-state-in-effect" }, { "title": "set-state-in-render", - "path": "/reference/eslint-plugin-react-hooks/lints/set-state-in-render", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/set-state-in-render" }, { "title": "static-components", - "path": "/reference/eslint-plugin-react-hooks/lints/static-components", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/static-components" }, { "title": "unsupported-syntax", - "path": "/reference/eslint-plugin-react-hooks/lints/unsupported-syntax", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/unsupported-syntax" }, { "title": "use-memo", - "path": "/reference/eslint-plugin-react-hooks/lints/use-memo", - "version": "rc" + "path": "/reference/eslint-plugin-react-hooks/lints/use-memo" } ] }, diff --git a/vercel.json b/vercel.json index 70ddefbe8b9..e467632b030 100644 --- a/vercel.json +++ b/vercel.json @@ -253,6 +253,11 @@ "source": "/reference/react/experimental_useEffectEvent", "destination": "/reference/react/useEffectEvent", "permanent": true + }, + { + "source": "/blog/2025/04/21/react-compiler-rc", + "destination": "/blog/2025/10/07/react-compiler-1", + "permanent": true } ], "headers": [