You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/manipulating-the-dom-with-refs.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -341,9 +341,9 @@ In this example, `itemsRef` doesn't hold a single DOM node. Instead, it holds a
341
341
342
342
This lets you read individual DOM nodes from the Map later.
343
343
344
-
<Canary>
344
+
<NextMajor>
345
345
346
-
This example shows another approach for managing the Map with a `ref` callback cleanup function.
346
+
Starting in React 19, callback refs can return a cleanup function. When the cleanup function is provided, React will not call the `ref` callback with `null` and call the cleanup function instead:
347
347
348
348
```js
349
349
<li
@@ -361,7 +361,7 @@ This example shows another approach for managing the Map with a `ref` callback c
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/client/createRoot.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,8 +45,8 @@ An app fully built with React will usually only have one `createRoot` call for i
45
45
46
46
* **optional** `options`: An object with options for this React root.
47
47
48
-
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`.
49
-
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onUncaughtError`: Callback called when an error is thrown and not caught by an Error Boundary. Called with the `error` that was thrown, and an `errorInfo` object containing the `componentStack`.
48
+
* <NextMajorBadge title="This feature is available in React 19 beta and the React canary channel" /> **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`.
49
+
* <NextMajorBadge title="This feature is available in React 19 beta and the React canary channel" /> **optional** `onUncaughtError`: Callback called when an error is thrown and not caught by an Error Boundary. Called with the `error` that was thrown, and an `errorInfo` object containing the `componentStack`.
50
50
* **optional** `onRecoverableError`: Callback called when React automatically recovers from errors. Called with an `error` React throws, and an `errorInfo` object containing the `componentStack`. Some recoverable errors may include the original error cause as `error.cause`.
51
51
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page.
52
52
@@ -346,11 +346,13 @@ It is uncommon to call `render` multiple times. Usually, your components will [u
346
346
347
347
### Show a dialog for uncaught errors {/*show-a-dialog-for-uncaught-errors*/}
348
348
349
-
<Canary>
349
+
<NextMajor>
350
350
351
-
`onUncaughtError` is only available in the latest React Canary release.
351
+
`onUncaughtError` is available in React 19 beta, and the React canary channel.
352
352
353
-
</Canary>
353
+
Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
354
+
355
+
</NextMajor>
354
356
355
357
By default, React will log all uncaught errors to the console. To implement your own error reporting, you can provide the optional `onUncaughtError` root option:
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/client/hydrateRoot.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,8 +41,8 @@ React will attach to the HTML that exists inside the `domNode`, and take over ma
41
41
42
42
* **optional** `options`: An object with options for this React root.
43
43
44
-
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`.
45
-
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onUncaughtError`: Callback called when an error is thrown and not caught by an Error Boundary. Called with the `error` that was thrown and an `errorInfo` object containing the `componentStack`.
44
+
* <NextMajorBadge title="This feature is available in React 19 beta and the React canary channel" /> **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`.
45
+
* <NextMajorBadge title="This feature is available in React 19 beta and the React canary channel" /> **optional** `onUncaughtError`: Callback called when an error is thrown and not caught by an Error Boundary. Called with the `error` that was thrown and an `errorInfo` object containing the `componentStack`.
46
46
* **optional** `onRecoverableError`: Callback called when React automatically recovers from errors. Called with the `error` React throws, and an `errorInfo` object containing the `componentStack`. Some recoverable errors may include the original error cause as `error.cause`.
47
47
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as used on the server.
48
48
@@ -376,11 +376,13 @@ It is uncommon to call [`root.render`](#root-render) on a hydrated root. Usually
376
376
377
377
### Show a dialog for uncaught errors {/*show-a-dialog-for-uncaught-errors*/}
378
378
379
-
<Canary>
379
+
<NextMajor>
380
380
381
-
`onUncaughtError` is only available in the latest React Canary release.
381
+
`onUncaughtError` is currently available in React 19 beta, and the React canary channel.
382
382
383
-
</Canary>
383
+
Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
384
+
385
+
</NextMajor>
384
386
385
387
By default, React will log all uncaught errors to the console. To implement your own error reporting, you can provide the optional `onUncaughtError` root option:
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/components/common.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -259,9 +259,10 @@ React will also call your `ref` callback whenever you pass a *different* `ref` c
259
259
260
260
*`node`: A DOM node or `null`. React will pass you the DOM node when the ref gets attached, and `null` when the `ref` gets detached. Unless you pass the same function reference for the `ref` callback on every render, the callback will get temporarily detached and re-attached during every re-render of the component.
261
261
262
-
<Canary>
262
+
<NextMajor>
263
263
264
264
#### Returns {/*returns*/}
265
+
In React 19 beta, ref callbacks can return a cleanup function. When a cleanup function is provided, React will not call the `ref` callback with `null` and will call the cleanup function instead.
265
266
266
267
***optional**`cleanup function`: When the `ref` is detached, React will call the cleanup function. If a function is not returned by the `ref` callback, React will call the callback again with `null` as the argument when the `ref` gets detached.
267
268
@@ -282,7 +283,7 @@ React will also call your `ref` callback whenever you pass a *different* `ref` c
282
283
* When Strict Mode is on, React will **run one extra development-only setup+cleanup cycle** before the first real setup. This is a stress-test that ensures that your cleanup logic "mirrors" your setup logic and that it stops or undoes whatever the setup is doing. If this causes a problem, implement the cleanup function.
283
284
* When you pass a *different*`ref` callback, React will call the *previous* callback's cleanup function if provided. If not cleanup function is defined, the `ref` callback will be called with `null` as the argument. The *next* function will be called with the DOM node.
0 commit comments