# @kne/react-error-boundary

> 用于捕捉react组件错误

Latest version **0.1.1** (published 2021-12-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install @kne/react-error-boundary
pnpm add @kne/react-error-boundary
yarn add @kne/react-error-boundary
bun add @kne/react-error-boundary
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-12-16 |
| First published | 2020-05-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 40 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | linzp |
| Maintainers | lingtong, evewei |
| Keywords | react, form, validate |

## Links

- npm: https://www.npmjs.com/package/@kne/react-error-boundary
- Repository: https://github.com/kne-union/react-error-boundary
- Homepage: https://github.com/kne-union/react-error-boundary#readme
- Issues: https://github.com/kne-union/react-error-boundary/issues
- npm.io page: https://npm.io/package/@kne/react-error-boundary

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.7.7

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2021-12-16
- 0.1.0 — 2020-05-08

## README

# react-error-boundary
用于捕捉react组件错误

```shell script
npm i @kne/react-error-boundary
```

# 使用示例

```jsx
import ErrorBoundary from '@kne/react-error-boundary';

const ErrorComponent = ({error})=>{
  console.error(error);
  return <div>组件发生错误</div>
}

const SomeComponent = ()=>{
  return <ErrorBoundary errorComponent={ErrorComponent}>
    <SomeComponent />
  </ErrorBoundary> 
};

const SomeComponent2 = ()=>{
  return <ErrorBoundary errorRender={(error)=>{
    console.error(error);
    return <div>组件发生错误</div>
  }}>
    <SomeComponent />
  </ErrorBoundary> 
};
```

# API

|属性名|说明|类型|默认值|
|  ---  | ---  | --- | --- |
|errorComponent|当子组件发生错误的时候渲染该组件，并传入属性error|Component|- |
|errorRender|当子组件发生错误的时候执行该方法，并传入参数error，需要返回jsx，注意:当errorComponent存在时该方法会被忽略|func|- |
|onError|当子组件发生错误的时候执行该方法|func|- |

# Change Log:

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