JSPM

  • Created
  • Published
  • Downloads 6954153
  • Score
    100M100P100Q282722F
  • License MIT

Sample reusable React error boundary component for React 16+

Package Exports

  • react-error-boundary

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-error-boundary) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-error-boundary

Sample reusable React error boundary component for React 16+

import ErrorBoundary from 'react-error-boundary';

// The simplest way to use a boundary;
// Wrap around any component that may throw an error:
<ErrorBoundary>
  <ComponentThatMayError />
</ErrorBoundary>

// You can also react to errors (eg for logging):
const myErrorHandler = (error, componentStack) => {/* ... */}
<ErrorBoundary onError={myErrorHandler}>
  <ComponentThatMayError />
</ErrorBoundary>

// You can also customize the fallback appearance:
const MyFallbackComponent = ({ componentStack, error }) => (/* ... */)
<ErrorBoundary FallbackComponent={MyFallbackComponent}>
  <ComponentThatMayError />
</ErrorBoundary>