# sweetalert2-react

> Declarative SweetAlert 2 in React

Latest version **0.8.3** (published 2019-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install sweetalert2-react
pnpm add sweetalert2-react
yarn add sweetalert2-react
bun add sweetalert2-react
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.3 |
| Published | 2019-08-14 |
| First published | 2017-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 5 |
| Unpacked size | 287.2 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 45 |
| Author | Shamshurin Alexander |
| Maintainers | alex.shamshurin |
| Keywords | alert, sweetalert, react, component, react-component |

## Links

- npm: https://www.npmjs.com/package/sweetalert2-react
- Repository: https://github.com/alex-shamshurin/sweetalert2-react
- Homepage: https://github.com/alex-shamshurin/sweetalert2-react#readme
- Issues: https://github.com/alex-shamshurin/sweetalert2-react/issues
- npm.io page: https://npm.io/package/sweetalert2-react

## Dependencies (5)

- [warning](https://npm.io/package/warning.md) ^4.0.3
- [mousetrap](https://npm.io/package/mousetrap.md) ^1.6.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.0.0
- [lodash.pick](https://npm.io/package/lodash.pick.md) ^4.4.0
- [sweetalert2](https://npm.io/package/sweetalert2.md) ^8.5.0

## 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.8.3 (latest) — 2019-08-14
- 0.8.2 — 2019-06-23
- 0.8.1 — 2019-03-19
- 0.8.0 — 2019-03-18
- 0.7.2 — 2018-03-19
- 0.7.1 — 2018-03-08
- 0.7.0 — 2018-03-08
- 0.6.0 — 2018-03-08
- 0.5.0 — 2017-09-09
- 0.4.10 — 2017-09-09

## README

# sweetalert2-react

[![npm version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Downloads][downloads-image]][downloads-url]

> Declarative SweetAlert in React

## Introduction

This is a React SweetAlert wrapper for https://github.com/limonte/sweetalert2

## Install

```
$ npm install sweetalert2-react
```

## Usage

```js
import React, { Component } from 'react';
import SweetAlert from 'sweetalert2-react';

// ...

render() {
  return (
    <div>
      <button onClick={() => this.setState({ show: true })}>Alert</button>
      <SweetAlert
        show={this.state.show}
        title="Demo"
        text="SweetAlert in React"
        onConfirm={() => this.setState({ show: false })}
      />
    </div>
  );
}
```

Since 0.6, you can wrap your own sweetalert2 (swal) instance:

```js
import React, { Component } from 'react';
import { withSwalInstance } from 'sweetalert2-react';
import swal from 'sweetalert2';

const SweetAlert = withSwalInstance(swal);

// ...

render() {
  return (
    <div>
      <button onClick={() => this.setState({ show: true })}>Alert</button>
      <SweetAlert
        show={this.state.show}
        title="Demo"
        text="SweetAlert in React"
        onConfirm={() => this.setState({ show: false })}
      />
    </div>
  );
}
```

## Tests

Tests were not updated to support sweetalert2. PRs are welcome.

## License

MIT © [C.T. Lin](https://github.com/alex-shamshurin/sweetalert2-react)


[npm-url]: https://npmjs.org/package/sweetalert2-react
[travis-image]: https://img.shields.io/travis/alex-shamshurin/sweetalert2-react.svg?style=flat-square
[travis-url]: https://travis-ci.org/alex-shamshurin/sweetalert2-react
[coveralls-image]: https://img.shields.io/coveralls/alex-shamshurin/sweetalert2-react.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/alex-shamshurin/sweetalert2-react
[npm-image]: https://img.shields.io/npm/v/sweetalert2-react.svg?style=flat-square
[downloads-image]: http://img.shields.io/npm/dm/sweetalert2-react.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/sweetalert2-react

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