From a61669a3ce6584ce6eb6fbd0420a9e7d9e4dfd18 Mon Sep 17 00:00:00 2001 From: Johanna Date: Wed, 29 Oct 2025 14:46:38 +0100 Subject: [PATCH 1/2] docs: add note on error boundary limitations --- src/content/reference/react/Component.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/content/reference/react/Component.md b/src/content/reference/react/Component.md index 9d2d1007b9e..ab6553645b7 100644 --- a/src/content/reference/react/Component.md +++ b/src/content/reference/react/Component.md @@ -1271,6 +1271,16 @@ We recommend defining components as functions instead of classes. [See how to mi By default, if your application throws an error during rendering, React will remove its UI from the screen. To prevent this, you can wrap a part of your UI into an *Error Boundary*. An Error Boundary is a special component that lets you display some fallback UI instead of the part that crashed--for example, an error message. + +Error boundaries do not catch errors for: + +- Event handlers [(learn more)](/learn/responding-to-events) +- Asynchronous code (e.g. `setTimeout` or `requestAnimationFrame` callbacks) +- [Server side rendering](/reference/react-dom/server) +- Errors thrown in the error boundary itself (rather than its children) + + + To implement an Error Boundary component, you need to provide [`static getDerivedStateFromError`](#static-getderivedstatefromerror) which lets you update state in response to an error and display an error message to the user. You can also optionally implement [`componentDidCatch`](#componentdidcatch) to add some extra logic, for example, to log the error to an analytics service. With [`captureOwnerStack`](/reference/react/captureOwnerStack) you can include the Owner Stack during development. From cc58ff310ec3b3a048fad14f68717ebb8d132af5 Mon Sep 17 00:00:00 2001 From: Johanna Date: Wed, 29 Oct 2025 16:29:55 +0100 Subject: [PATCH 2/2] docs: add startTransition exception to the note --- src/content/reference/react/Component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/reference/react/Component.md b/src/content/reference/react/Component.md index ab6553645b7..2509aa7598a 100644 --- a/src/content/reference/react/Component.md +++ b/src/content/reference/react/Component.md @@ -1275,9 +1275,9 @@ By default, if your application throws an error during rendering, React will rem Error boundaries do not catch errors for: - Event handlers [(learn more)](/learn/responding-to-events) -- Asynchronous code (e.g. `setTimeout` or `requestAnimationFrame` callbacks) - [Server side rendering](/reference/react-dom/server) - Errors thrown in the error boundary itself (rather than its children) +- Asynchronous code (e.g. `setTimeout` or `requestAnimationFrame` callbacks); an exception is the usage of the [`startTransition`](/reference/react/useTransition#starttransition) function returned by the [`useTransition`](/reference/react/useTransition) Hook. Errors thrown inside the transition function are caught by error boundaries [(learn more)](/reference/react/useTransition#displaying-an-error-to-users-with-error-boundary)