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
Sample reusable React error boundary component for React 16+
4
+
**A simple, reusable React error boundary component for React 16+.**
4
5
5
-
The simplest way to use a boundary is to wrap it around any component that may throw an error.
6
-
This will handle errors thrown by that component's descendants also.
6
+
React [v16](https://reactjs.org/blog/2017/09/26/react-v16.0.html) introduced the concept of [“error boundaries”](https://reactjs.org/docs/error-boundaries.html).
7
+
8
+
This component provides a simple and reusable wrapper that you can use to wrap around your components. Any rendering errors in your components hierarchy can then be gracefully handled.
9
+
10
+
# Usage
11
+
12
+
The simplest way to use `<ErrorBoundary>` is to wrap it around any component that may throw an error.
13
+
This will handle errors thrown by that component and its descendants too.
7
14
8
15
```jsx
9
16
importErrorBoundaryfrom'react-error-boundary';
@@ -13,40 +20,53 @@ import ErrorBoundary from 'react-error-boundary';
13
20
</ErrorBoundary>
14
21
```
15
22
16
-
You can react to errors (eg for logging) by providing an `onError` callback:
23
+
You can react to errors (e.g. for logging) by providing an `onError` callback:
0 commit comments