@s-ui/react-error-app-boundary

Sample reusable React error boundary component for React 16+

Usage no npm install needed!

<script type="module">
  import sUiReactErrorAppBoundary from 'https://cdn.skypack.dev/@s-ui/react-error-app-boundary';
</script>

README

ErrorAppBoundary

Sample reusable React error boundary component for React 16+

The simplest way to use a boundary is to wrap it around any component that may throw an error. This will handle errors thrown by that component's descendents also. This component is specially prepared to wrap your whole App in order to show a message to the user when an unexpected Error happened.

Installation

$ npm install @s-ui/react-error-appBoundary --save

Basic usage

import ErrorAppBoundary from '@s-ui/react-error-appBoundary'

return (
  <ErrorAppBoundary
    buttonLabel='OK!'
    message='Oops! An error has occurred! Nasty plasty! Sorry!'
    onError={({ errorMessage, errorStack }) => console.error({ errorMessage, errorStack })}
  >
    <main>
      <AppHeader />
      <BodyContent />
      <Footer />
    </main>
  </ErrorAppBoundary>
)

Find full description and more examples in the demo page.