# twcm-error-modal

> Error Modal for use with TWC public platforms

Latest version **0.2.2** (published 2017-10-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install twcm-error-modal
pnpm add twcm-error-modal
yarn add twcm-error-modal
bun add twcm-error-modal
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2017-10-05 |
| First published | 2017-08-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | james@thewedclique.com |
| Maintainers | jmensch |

## Links

- npm: https://www.npmjs.com/package/twcm-error-modal
- Repository: https://github.com/Otterplan/twcm-errorModal
- Homepage: https://github.com/Otterplan/twcm-errorModal#readme
- Issues: https://github.com/Otterplan/twcm-errorModal/issues
- npm.io page: https://npm.io/package/twcm-error-modal

## Dependencies (4)

- [react](https://npm.io/package/react.md) ^15.6.1
- [deepmerge](https://npm.io/package/deepmerge.md) ^1.5.1
- [react-dom](https://npm.io/package/react-dom.md) ^15.6.1
- [material-ui](https://npm.io/package/material-ui.md) ^0.19.2

## Recent versions

- 0.2.2 (latest) — 2017-10-05
- 0.2.1 — 2017-10-04
- 0.2.0 — 2017-09-25
- 0.1.6 — 2017-09-13
- 0.1.5 — 2017-08-31
- 0.1.4 — 2017-08-31
- 0.1.3 — 2017-08-31
- 0.1.2 — 2017-08-31
- 0.1.1 — 2017-08-31
- 0.1.0 — 2017-08-31
- 0.0.10 — 2017-08-31
- 0.0.9 — 2017-08-30
- 0.0.8 — 2017-08-30
- 0.0.7 — 2017-08-30
- 0.0.6 — 2017-08-30
- … 5 more at https://npm.io/package/twcm-error-modal/versions

## README

# twcm-error-modal
Error module to be used for all TWC platforms.

## Installation
`yarn add twcm-error-modal`

## Example Usage
```
import * as React from 'react';
import ErrorModal from 'twcm-error-modal`

class TWCComponent extends React.Component<{}, { error: Error }> {
  constructor() {
    super();

    this.state = { error: null };

    this._closeError = this._closeError.bind(this);
  }

  public breakingCode(): JSX.Element {
    const onError = (e: Error) => this._handleError(e);
    willBreak()
      .catch(onError);
  }

  public render(): JSX.Element {
    <div>
      { this.breakingCode() }
      <ErrorModal
        isOpen={ !!this.state.error }
        err={ this.state.error }
        onClose={ this._clearError }
      />
    </div>
  }

  private _emitError(error: Error): void {
    this.setState({ error });
  }

  private _closeError(): void {
    this.setState({ error: null });
  }
}
```

## API
```
customMsg: string - Optional message to display
isOpen: boolean - (required)
err: Error - Full error object to display.
onClose: () => any; - (required) Function to run on modal exit.
```

customMsg?: string;
err?: Error;
isOpen: boolean;
onClose: () => void;

## Testing
1) Add some tests in a `*.spec.tsx` file
2) Run `yarn build`

## Contributing
1) Make some changes
2) Update tag in package.json
3) Ask james for NPM login info if you don't have one.
4) Run `npm publish` (CI doesn't deploy yet)
5) Commit & push code

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