Skip to content

Commit a61669a

Browse files
committed
docs: add note on error boundary limitations
1 parent 2c7798d commit a61669a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/content/reference/react/Component.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,16 @@ We recommend defining components as functions instead of classes. [See how to mi
12711271
12721272
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.
12731273
1274+
<Note>
1275+
Error boundaries do not catch errors for:
1276+
1277+
- Event handlers [(learn more)](/learn/responding-to-events)
1278+
- Asynchronous code (e.g. `setTimeout` or `requestAnimationFrame` callbacks)
1279+
- [Server side rendering](/reference/react-dom/server)
1280+
- Errors thrown in the error boundary itself (rather than its children)
1281+
1282+
</Note>
1283+
12741284
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.
12751285
12761286
With [`captureOwnerStack`](/reference/react/captureOwnerStack) you can include the Owner Stack during development.

0 commit comments

Comments
 (0)