Skip to content

React Error Boundary Component for catching ⚾️ errors.

Notifications You must be signed in to change notification settings

alesmenzel/error-boundary

Repository files navigation

Error Boundary

Simple implementation of React's Error Boundary.

Installation

npm install @alesmenzel/error-boundary

Usage

function App({ name }) {
  return (
    <ErrorBoundary
      onError={(error, info) => /* optionally, send to your favourite logger */ }
      fallback={({error, retry}) => <NoAvatar />}
      // or
      fallback={<NoAvatar />}
    >
      <Avatar name={name}/>
    </ErrorBoundary>
  )
}