|
| 1 | +--- |
| 2 | +title: "React 19.2" |
| 3 | +author: The React Team |
| 4 | +date: 2025/09/30 |
| 5 | +description: This release continues to build on the scheduling capabilities of concurrent rendering with Activity, adds performance tracks to help optimize your code for concurrent rendering, and new APIs to improve the developer experience. |
| 6 | +--- |
| 7 | + |
| 8 | +September 30, 2025 by [The React Team](/community/team) |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +<Intro> |
| 13 | + |
| 14 | +React 19.2 is now available on npm! |
| 15 | + |
| 16 | +</Intro> |
| 17 | + |
| 18 | + |
| 19 | +<Note> |
| 20 | + |
| 21 | +React Conf 2025 is October 7–8 in Henderson, Nevada! |
| 22 | + |
| 23 | +Watch the livestream on [the React Conf website](https://conf.react.dev). |
| 24 | + |
| 25 | +</Note> |
| 26 | + |
| 27 | +React 19.2 is our third release in the last year, following React 19 in December and React 19.1 in June. |
| 28 | + |
| 29 | +This release continues to build on the scheduling capabilities of concurrent rendering with Activity, adds performance tracks to help optimize your code for concurrent rendering, and new APIs to improve the developer experience. |
| 30 | + |
| 31 | +In this post, we'll give an overview of the new features in React 19.2, and how you can adopt them. |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## New Features {/*new-features*/} |
| 36 | + |
| 37 | +### `<Activity />` {/*activity*/} |
| 38 | + |
| 39 | +`<Activity>` lets you break your app into "activities" that can be controlled and prioritized. |
| 40 | + |
| 41 | +In React 19.2, Activity supports two modes: `visible` and `hidden`: |
| 42 | + |
| 43 | +```js |
| 44 | +<Activity mode={isVisible ? 'visible' : 'hidden'}> |
| 45 | + <Page /> |
| 46 | +</Activity> |
| 47 | +``` |
| 48 | + |
| 49 | +When an Activity is `visible` it’s rendered as normal on the client, and will defer hydration during SSR. When an Activity is `hidden` it is unmounted (adding `display:none` to the children) and is excluded from the SSR output. While an Activity is hidden, React will keep the hook and DOM state, and continue to render at a lower priority than anything visible on screen. |
| 50 | + |
| 51 | +You can use Activity to pre-render hidden parts of the app that a user is likely to navigate to next, or to save the state of parts the user navigates away from. This helps make navigations quicker, and allows back navigations to maintain state such as input fields. |
| 52 | + |
| 53 | +For more information, see the last [React Labs post](/blog/2025/04/23/react-labs-view-transitions-activity-and-more#activity) and the [Activity docs](/reference/react/activity). |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +### React Performance Tracks {/*react-performance-tracks*/} |
| 58 | + |
| 59 | + |
| 60 | +React 19.2 adds a new set of [custom tracks](https://developer.chrome.com/docs/devtools/performance/extension) to Chrome DevTools performance profiles to provide more information about the performance of your React app: |
| 61 | + |
| 62 | +<div style={{display: 'flex', justifyContent: 'center', marginBottom: '1rem'}}> |
| 63 | + <picture > |
| 64 | + <source srcset="/images/blog/react-labs-april-2025/perf_tracks.png" /> |
| 65 | + <img className="w-full light-image" src="/images/blog/react-labs-april-2025/perf_tracks.webp" /> |
| 66 | + </picture> |
| 67 | + <picture > |
| 68 | + <source srcset="/images/blog/react-labs-april-2025/perf_tracks_dark.png" /> |
| 69 | + <img className="w-full dark-image" src="/images/blog/react-labs-april-2025/perf_tracks_dark.webp" /> |
| 70 | + </picture> |
| 71 | +</div> |
| 72 | + |
| 73 | +For more information, see the [React Performance Tracks docs](/learn/react-performance-tracks). |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +### `useEffectEvent` {/*use-effect-event*/} |
| 78 | + |
| 79 | +When using Effects you may want to read the most recent props or state inside an Effect without causing the Effect to re-run when those values change. |
| 80 | + |
| 81 | +The typical workaround is to use a ref to store the latest `theme`, and read from that ref inside the Effect. This works, but it’s verbose and requires extra code, so in practice most users just disable the lint rule and leave the dependency out. |
| 82 | + |
| 83 | +Disabling the lint rule creates a refactor hazard, because the linter cannot help you if you later add a dependency that should be included. Here, `threadId` is added after the initial implementation, but the Effect does not re-run when `threadId` changes because it was not added to the dependency array: |
| 84 | + |
| 85 | +```js {1,3,12} |
| 86 | +function ChatRoom({ roomId, theme, threadId }) { |
| 87 | + useEffect(() => { |
| 88 | + const connection = createConnection(serverUrl, roomId + threadId); |
| 89 | + connection.on('connected', () => { |
| 90 | + showNotification('Connected!', theme); |
| 91 | + }); |
| 92 | + connection.connect(); |
| 93 | + return () => { |
| 94 | + connection.disconnect() |
| 95 | + }; |
| 96 | + // eslint-disable-next-line react-hooks/exhaustive-deps |
| 97 | + }, [roomId]); // 🚩 threadId is missing! |
| 98 | + // ... |
| 99 | +``` |
| 100 | +
|
| 101 | +To solve this problem, React 19.2 introduces `useEffectEvent`, which lets you declare Effect Events that can be called inside Effects. Effect Events always access the latest values from props and state when they are invoked, so you can read the latest values without re-running the Effect. |
| 102 | +
|
| 103 | +```js {2,3,4,9} |
| 104 | +function ChatRoom({ roomId, theme, threadId }) { |
| 105 | + const onConnected = useEffectEvent(() => { |
| 106 | + showNotification('Connected!', theme); |
| 107 | + }); |
| 108 | + |
| 109 | + useEffect(() => { |
| 110 | + const connection = createConnection(serverUrl, roomId, threadId); |
| 111 | + connection.on('connected', () => { |
| 112 | + onConnected(); |
| 113 | + }); |
| 114 | + connection.connect(); |
| 115 | + return () => connection.disconnect(); |
| 116 | + }, [roomId, threadId]); // ✅ All dependencies declared |
| 117 | + // ... |
| 118 | +``` |
| 119 | +
|
| 120 | +For more information, see [Separating Events from Effects](/learn/separating-events-from-effects) and the [`useEffectEvent` docs](/reference/react/useEffectEvent). |
| 121 | +
|
| 122 | +--- |
| 123 | +
|
| 124 | +### `cacheSignal` {/*cache-signal*/} |
| 125 | +
|
| 126 | +<RSC> |
| 127 | +
|
| 128 | +`cacheSignal` is only for use with [React Server Components](/reference/rsc/server-components). |
| 129 | +
|
| 130 | +</RSC> |
| 131 | +
|
| 132 | +`cacheSignal` allows you to know when the [`cache()`](/reference/react/cache) lifetime is over: |
| 133 | +
|
| 134 | +``` |
| 135 | +import {cache, cacheSignal} from 'react'; |
| 136 | +const dedupedFetch = cache(fetch); |
| 137 | + |
| 138 | +async function Component() { |
| 139 | + await dedupedFetch(url, { signal: cacheSignal() }); |
| 140 | +} |
| 141 | +``` |
| 142 | +
|
| 143 | +This allows you to clean up or abort work when the result will no longer be used in the cache, such as: |
| 144 | +
|
| 145 | +- React has successfully completed rendering |
| 146 | +- The render was aborted |
| 147 | +- The render has failed |
| 148 | +
|
| 149 | +For more info, see the [`cacheSignal` docs](/reference/react/cacheSignal). |
| 150 | +
|
| 151 | +--- |
| 152 | +
|
| 153 | +## Notable Changes {/*notable-changes*/} |
| 154 | +
|
| 155 | +### Batching Suspense Boundaries for SSR {/*batching-suspense-boundaries-for-ssr*/} |
| 156 | +
|
| 157 | +We fixed a long-standing behavior bug where Suspense boundaries would reveal differently depending on if they were rendered on the client or when streaming from server-side rendering. |
| 158 | +
|
| 159 | +Starting in 19.2, React will batch reveals of server-rendered Suspense boundaries for a short time, to allow more content to be revealed together and align with the client-rendered behavior. |
| 160 | +
|
| 161 | +<Diagram name="19_2_batching_before" height={162} width={1270} alt="Diagram with three sections, with an arrow transitioning each section in between. The first section contains a page rectangle showing a glimmer loading state with faded bars. The second panel shows the top half of the page revealed and highlighted in blue. The third panel shows the entire the page revealed and highlighted in blue."> |
| 162 | +
|
| 163 | +Previously, during streaming server-side rendering, suspense content would immediately replace fallbacks. |
| 164 | +
|
| 165 | +</Diagram> |
| 166 | +
|
| 167 | +<Diagram name="19_2_batching_after" height={162} width={1270} alt="Diagram with three sections, with an arrow transitioning each section in between. The first section contains a page rectangle showing a glimmer loading state with faded bars. The second panel shows the same page. The third panel shows the entire the page revealed and highlighted in blue."> |
| 168 | +
|
| 169 | +In React 19.2, suspense boundaries are batched for a small amount of time, to allow revealing more content together. |
| 170 | +
|
| 171 | +</Diagram> |
| 172 | +
|
| 173 | +This fix also prepares apps for supporting `<ViewTransition>` for Suspense during SSR. By revealing more content together, animations can run in larger batches of content, and avoid chaining animations of content that streams in close together. |
| 174 | +
|
| 175 | +<Note> |
| 176 | +
|
| 177 | +React uses heuristics to ensure throttling does not impact core web vitals and search ranking. |
| 178 | +
|
| 179 | +For example, if the total page load time is approaching 2.5s (which is the time considered "good" for [LCP](https://web.dev/articles/lcp)), React will stop batching and reveal content immediately so that the throttling is not the reason to miss the metric. |
| 180 | +
|
| 181 | +</Note> |
| 182 | +
|
| 183 | +--- |
| 184 | +
|
| 185 | +### SSR: Web Streams support for Node {/*ssr-web-streams-support-for-node*/} |
| 186 | +
|
| 187 | +React 19.2 adds support for Web Streams for streaming SSR in Node.js: |
| 188 | +- [`renderToReadableStream`](/reference/react-dom/server/renderToReadableStream) is now available for Node.js |
| 189 | +- [`prerender`](/reference/react-dom/static/prerender) is now available for Node.js |
| 190 | +
|
| 191 | +<Pitfall> |
| 192 | +
|
| 193 | +We still highly recommend using Node Streams for streaming server-side rendering in Node environments because Node Streams are much faster than Web Streams, and Web Streams do not support compression by default, leading to users accidentally missing the benefits of streaming. |
| 194 | +
|
| 195 | +</Pitfall> |
| 196 | +
|
| 197 | +--- |
| 198 | +
|
| 199 | +### Update the default `useId` prefix {/*update-the-default-useid-prefix*/} |
| 200 | +
|
| 201 | +In 19.2, we're updating the default `useId` prefix from `:r:` (19.0.0) or `«r»` (19.1.0) to `_r_`. |
| 202 | +
|
| 203 | +The original intent of using a special character that was not valid for CSS selectors was that it would be unlikely to collide with IDs written by users. However, to support View Transitions, we need to ensure that IDs generated by `useId` are valid for `view-transition-name` and XML 1.0 names. |
| 204 | +
|
| 205 | +--- |
| 206 | +
|
| 207 | +## Changelog {/*changelog*/} |
| 208 | +
|
| 209 | +Other notable changes |
| 210 | +- `react-dom`: Allow nonce to be used on hoistable styles [#32461](https://github.com/facebook/react/pull/32461) |
| 211 | +- `react-dom`: Warn for using a React owned node as a Container if it also has text content [#32774](https://github.com/facebook/react/pull/32774) |
| 212 | +
|
| 213 | +Notable bug fixes |
| 214 | +- `react`: Stringify context as "SomeContext" instead of "SomeContext.Provider" [#33507](https://github.com/facebook/react/pull/33507) |
| 215 | +- `react`: Fix infinite useDeferredValue loop in popstate event [#32821](https://github.com/facebook/react/pull/32821) |
| 216 | +- `react`: Fix a bug when an initial value was passed to useDeferredValue [#34376](https://github.com/facebook/react/pull/34376) |
| 217 | +- `react`: Fix a crash when submitting forms with Client Actions [#33055](https://github.com/facebook/react/pull/33055) |
| 218 | +- `react`: Hide/unhide the content of dehydrated suspense boundaries if they resuspend [#32900](https://github.com/facebook/react/pull/32900) |
| 219 | +- `react`: Avoid stack overflow on wide trees during Hot Reload [#34145](https://github.com/facebook/react/pull/34145) |
| 220 | +- `react`: Improve component stacks in various places [#33629](https://github.com/facebook/react/pull/33629), [#33724](https://github.com/facebook/react/pull/33724), [#32735](https://github.com/facebook/react/pull/32735), [#33723](https://github.com/facebook/react/pull/33723) |
| 221 | +- `react`: Fix a bug with React.use inside React.lazy-ed Component (@hi-ogawa [#33941](https://github.com/facebook/react/pull/33941) |
| 222 | +- `react-dom`: Stop warning when ARIA 1.3 attributes are used (@Abdul-Omira [#34264](https://github.com/facebook/react/pull/34264) |
| 223 | +- `react-dom`: Fix a bug with deeply nested Suspense inside Suspense fallbacks [#33467](https://github.com/facebook/react/pull/33467) |
| 224 | +- `react-dom`: Avoid hanging when suspending after aborting while rendering (@gnoff [#34192)]() |
| 225 | +
|
| 226 | +For a full list of changes, please see the [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md). |
| 227 | +
|
| 228 | +
|
| 229 | +--- |
| 230 | +
|
| 231 | +_Thanks to everyone who helped review this post._ |
0 commit comments