react-boundary
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-boundary

npm version gzip size license

Error boundaries, the hooky way.

Installation

npm install react-boundary

or

yarn add react-boundary

Usage

import { boundary, useError } from 'react-boundary';
 
const Component = boundary(() => {
  const [error, info] = useError();
 
  return error && info ? (
    <span>
      Oh no! Something happened{error.message}
      {info.componentStack}
    </span>
  ) : (
    <span>
      Everything is fine
    </span>
  );
});

Package Sidebar

Install

npm i react-boundary

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

14.6 kB

Total Files

23

Last publish

Collaborators

  • houfio