@matthamlin/react-error-boundary

1.0.0 • Public • Published

React-Error-Boundary 🚯

An unopinionated <ErrorBoundary /> React component for React 16+.

<div>
  <ErrorBoundary
    onCaughtError={logError}
  >
    {error => error
      ? (
        <h1>Oh no an error occurred!</h1>
      )
      : (
        <Application />
      )
    }
  </ErrorBoundary>
</div>

Props:

  • onCaughtError method called after <ErrorBoundary /> catches an error.
    • type function
    • Called with one argument, the error object thrown
  • children function called inside render
    • Called with the error object, will be null initially
    • This is the only thing returned from render, so you have full control over rendering

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i @matthamlin/react-error-boundary

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    144 kB

    Total Files

    24

    Last publish

    Collaborators

    • matthamlin