@invisionag/iris-react-error-boundary

3.5.2 • Public • Published
import ErrorBoundary from '@invisionag/iris-react-errorboundary';

react-error-boundary is a component that catches JavaScript errors anywhere in its child component tree and displays a fallback UI instead. This prevents the entire react app from unmounting by using React 16's componentDidCatch lifecycle method.

Usage

Basic

Renders a fallback UI when <SomeComponent /> throws an error. (As seen in the default Story)

<ErrorBoundary>
  <SomeComponent />
</ErrorBoundary>

showStackTrace

When using the default fallback UI the showStackTrace prop controlles if the stacktrace is shown. By default the stacktrace isn't shown in the production enviroment.

// Will never show the stacktrace
<ErrorBoundary showStackTrace={false}>
  <SomeComponent />
</ErrorBoundary>

renderError

The renderError prop lets you render a custom fallback UI. It expects a function that takes an ErrorObject and returns a React Node.

type ErrorObject = {
  error: Error,
  componentStack: string,
};

renderError = (errorObject: ErrorObject) => (
  <SomeAlternateComponent errorObject={errorObject} />
);

<ErrorBoundary renderError={renderError}>
  <SomeComponent />
</ErrorBoundary>

Readme

Keywords

none

Package Sidebar

Install

npm i @invisionag/iris-react-error-boundary

Weekly Downloads

37

Version

3.5.2

License

MIT

Unpacked Size

21.1 kB

Total Files

9

Last publish

Collaborators

  • jj-ivx
  • ivx-github
  • jana_hehr
  • roberter26
  • birgithorn
  • alexj-ivx
  • amft
  • aitortomas
  • yashabfaryal0322
  • nleinich
  • johannesluedke
  • pgotthardt-ivx
  • hrabe
  • plore_ivx
  • patricialieske
  • plaudel
  • mblumtritt
  • sruehlemann
  • brerx
  • mohamedmmahfouz
  • mbrendler
  • jens.zobel
  • cwaider
  • kattelans
  • ftrautmann
  • lutz.peukert
  • fruetel
  • schmitze333
  • csprle
  • beckerei
  • stefan.schiffer
  • ahx
  • cloudwaechter
  • tobias
  • alexmarold
  • t_klepzig
  • susahope
  • mwannewitz
  • ivx-circle-ci
  • yichang
  • ivx-jenkins