@@ -271,7 +272,66 @@ Errors will bubble up to the nearest parent error boundary. This allows for gran
height="687"
/>
Errorboundariesdon’tcatcherrorsinsideeventhandlers.They’redesignedtocatcherrors[duringrendering](https://react.dev/reference/react/Component#static-getderivedstatefromerror) to show a **fallback UI** instead of crashing the whole app.
Errorboundariesdon't catch errors inside event handlers. They'redesignedtocatcherrors[duringrendering](https://react.dev/reference/react/Component#static-getderivedstatefromerror) to show a **fallback UI** instead of crashing the whole app.
> - The [React DevTools](https://react.dev/learn/react-developer-tools) allow you to toggle error boundaries to test error states.
> - If you want errors to bubble up to the parent error boundary, you can `throw` when rendering the `error` component.
> - For component-level error recovery that aren't tied to route segments like [`error.js`](/docs/app/api-reference/file-conventions/error), use the [`unstable_catchError`](/docs/app/api-reference/functions/catchError) function.
In the [component hierarchy](/docs/app/getting-started/project-structure#component-hierarchy), `error.js` wraps `loading.js`, `not-found.js`, `page.js`, and nested `layout.js` files in a React error boundary. It does **not** wrap the `layout.js` or `template.js` above it in the same segment. To handle errors in the root layout, use [`global-error.js`](/docs/app/api-reference/file-conventions/error#global-error).
|`unstable_retry`|`() => void`|Re-fetchesandre-renderstheerrorboundary's contents. If successful, the fallback is replaced with the re-rendered result. |
| `reset` | `() => void` | Resets the error state and re-renders without re-fetching. Use [`retry()`](/docs/app/api-reference/file-conventions/error#unstable_retry) in most cases. |
The `fallback` function must be a Client Component (or defined in a `'useclient'` module).
### Returns
`unstable_catchError` returns a React component that:
- Accepts the same props as your fallback'sfirstargument,plus`children`.
Use`retry()`toprompttheusertorecoverfromtheerror.Whencalled,thefunctionre-fetchesandre-renderstheerrorboundary's contents. If successful, the fallback is replaced with the re-rendered result.
In most cases, use `retry()` instead of `reset()`. The `reset()` function only clears the error state and re-renders without re-fetching, which means it won'trecoverfromServerComponenterrors.