# babel-plugin-component-did-catch-source

> Babel plugin to add source fiber for use in componentDidCatch

Latest version **1.0.2** (published 2018-08-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-component-did-catch-source
pnpm add babel-plugin-component-did-catch-source
yarn add babel-plugin-component-did-catch-source
bun add babel-plugin-component-did-catch-source
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-08-26 |
| First published | 2018-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 74.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vincent Taverna |
| Maintainers | vinnymac |
| Keywords | babel, babel-plugin, react, debug, error, componentDidCatch |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-component-did-catch-source
- Repository: https://github.com/vinnymac/babel-plugin-component-did-catch-source
- Homepage: https://github.com/vinnymac/babel-plugin-component-did-catch-source#readme
- Issues: https://github.com/vinnymac/babel-plugin-component-did-catch-source/issues
- npm.io page: https://npm.io/package/babel-plugin-component-did-catch-source

## 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

- 1.0.2 (latest) — 2018-08-26
- 1.0.1 — 2018-08-26
- 1.0.0 — 2018-08-26

## README

# babel-plugin-component-did-catch-source

> Add fiber source to `componentDidCatch` info argument.

## Installation

```sh
npm install --save-dev babel-plugin-component-did-catch-source
```

## The Problem

Need access to the source fiber but react's `componentDidCatch` does not provide it. Maintaining a fork of React is not as flexible as a compile time change.

## Example

**Before**
```jsx
class ErrorBoundary extends Component {
  componentDidCatch(error, { componentStack }) {
    errorLogger(componentStack)
  }
}
```

**After**
```jsx
class ErrorBoundary extends Component {
  componentDidCatch(error, { componentStack, source }) {
    const { props, state } = source.stateNode

    errorLogger(componentStack, props, state)
  }
}
```

## Usage

### Via `.babelrc.js` (Recommended)

**.babelrc**

```json
{
  "env": {
    "production": {
      "plugins": ["component-did-catch-source"]
    }
  }
}
```

### Via CLI

```sh
babel --plugins component-did-catch-source script.js
```

### Via Node

```js
require('babel-core').transform('code', {
  plugins: [
    'component-did-catch-source',
  ],
});
```

## Options

None yet

## Notes

This plugin will likely only work with v16 of React.

## License

MIT

---
_Source: https://npm.io/package/babel-plugin-component-did-catch-source · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
