@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>

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

    Package Sidebar

    Install

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

    Weekly Downloads

    65

    Version

    3.5.2

    License

    MIT

    Unpacked Size

    21.1 kB

    Total Files

    9

    Last publish

    Collaborators

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