Skip to content

Commit faab19d

Browse files
cbasdevclaude
andcommitted
Document errorInfo.errorBoundary in onCaughtError
React passes the Error Boundary instance that caught the error as errorInfo.errorBoundary to onCaughtError (since react#28641), but the createRoot and hydrateRoot docs only mentioned componentStack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7594a2b commit faab19d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/content/reference/react-dom/client/createRoot.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ An app fully built with React will usually only have one `createRoot` call for i
4545
4646
* **optional** `options`: An object with options for this React root.
4747
48-
* **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`.
48+
* **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` and the `errorBoundary` instance that caught the error.
4949
* **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`.
5050
* **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`.
5151
* **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.
@@ -377,7 +377,7 @@ const root = createRoot(container, {
377377
The <CodeStep step={1}>onCaughtError</CodeStep> option is a function called with two arguments:
378378
379379
1. The <CodeStep step={2}>error</CodeStep> that was thrown.
380-
2. An <CodeStep step={3}>errorInfo</CodeStep> object that contains the <CodeStep step={4}>componentStack</CodeStep> of the error.
380+
2. An <CodeStep step={3}>errorInfo</CodeStep> object that contains the <CodeStep step={4}>componentStack</CodeStep> of the error and the `errorBoundary` instance that caught it.
381381
382382
Together with `onUncaughtError` and `onRecoverableError`, you can implement your own error reporting system:
383383

‎src/content/reference/react-dom/client/hydrateRoot.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ React will attach to the HTML that exists inside the `domNode`, and take over ma
4141
4242
* **optional** `options`: An object with options for this React root.
4343
44-
* **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`.
44+
* **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` and the `errorBoundary` instance that caught the error.
4545
* **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`.
4646
* **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`.
4747
* **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.
@@ -407,7 +407,7 @@ const root = hydrateRoot(container, <App />, {
407407
The <CodeStep step={1}>onCaughtError</CodeStep> option is a function called with two arguments:
408408
409409
1. The <CodeStep step={2}>error</CodeStep> that was thrown.
410-
2. An <CodeStep step={3}>errorInfo</CodeStep> object that contains the <CodeStep step={4}>componentStack</CodeStep> of the error.
410+
2. An <CodeStep step={3}>errorInfo</CodeStep> object that contains the <CodeStep step={4}>componentStack</CodeStep> of the error and the `errorBoundary` instance that caught it.
411411
412412
Together with `onUncaughtError` and `onRecoverableError`, you can implement your own error reporting system:
413413

0 commit comments

Comments
 (0)