# error-boundary-jsx

> React (JS) string formatting

Latest version **2.0.6** (published 2020-09-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install error-boundary-jsx
pnpm add error-boundary-jsx
yarn add error-boundary-jsx
bun add error-boundary-jsx
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2020-09-14 |
| First published | 2019-10-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Nicky Shannon @nickyshannon |
| Maintainers | monkey3310 |
| Keywords | error boundary jsx, error catch, error |

## Links

- npm: https://www.npmjs.com/package/error-boundary-jsx
- Repository: https://github.com/agoda-com/react-handyman
- Homepage: https://github.com/agoda-com/react-handyman#readme
- Issues: https://github.com/agoda-com/react-handyman/issues
- npm.io page: https://npm.io/package/error-boundary-jsx

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 2.0.6 (latest) — 2020-09-14
- 2.0.5 — 2020-07-17
- 2.0.4 — 2020-07-17
- 2.0.3 — 2020-07-16
- 2.0.2 — 2020-07-13
- 2.0.1 — 2020-07-09
- 2.0.0 — 2020-03-13
- 1.0.6 — 2019-11-29
- 1.0.5 — 2019-11-21
- 1.0.4 — 2019-10-23
- 1.0.3 — 2019-10-19
- 1.0.2 — 2019-10-18
- 1.0.1 — 2019-10-02
- 1.0.0 — 2019-10-01

## README

[![npm](https://img.shields.io/npm/v/error-boundary.svg)](https://www.npmjs.com/package/error-boundary-jsx)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/error-boundary.svg)](https://bundlephobia.com/result?p=error-boundary-jsx)
[![Build Status](https://travis-ci.org/agoda-com/react-handyman.svg?branch=master)](https://travis-ci.org/agoda-com/react-handyman)
[![codecov](https://codecov.io/gh/agoda-com/react-handyman/branch/master/graph/badge.svg)](https://codecov.io/gh/agoda-com/react-handyman)
[![dependabot badge](https://badgen.net/dependabot/agoda-com/react-handyman/?icon=dependabot.svg)](https://dependabot.com/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

# error-boundary-jsx

Handle errors on wrapped component and provide a fall back.

```bash
yarn add error-boundary-jsx

# or with npm

npm install error-boundary-jsx --save
```

### `<ErrorBoundary />` Component (Recommended)

Handle errors for specific use case of component.

```ts
import ErrorBoundary from 'error-boundary-jsx'

<ErrorBoundary onError={componentErrorHandler} name="component name" FallbackComponent={CustomFallbackComponent}>
    ...component tree to handle errors
</ErrorBoundary>
```

### `withErrorBoundary()` HOC

HOC for error handling every use case of a component.

```ts
import withErrorBoundary from 'error-boundary-jsx'

const componentErrorHandler = {
    handleComponentError(error: Error, name: string, stack: string): void {
        ...log error
    }
}

withErrorBoundary(Component, componentErrorHandler)
```

##### API

| prop       | type                   | required | defaultValue | Description                                                                                                                    |
| ---------- | ---------------------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `component` | `React.ComponentType`     | true     | -            | A component that we want to bind error boundary jsx to                                                        |
| `name`      | `string`     | true     | -            | Component name to identify in stack message                                                       |
| `onError`  | `(name: string, error: Error, stack: string) => void`     | true     | -            | Error callback handler                                                     |
| `FallbackComponent` | `React.ComponentType`     | false     | -            | A fallback component when error occurs                                                       |

---
_Source: https://npm.io/package/error-boundary-jsx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
