# @opuscapita/react-notifications

> Notification component for ReactJS

Latest version **1.4.3** (published 2020-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @opuscapita/react-notifications
pnpm add @opuscapita/react-notifications
yarn add @opuscapita/react-notifications
bun add @opuscapita/react-notifications
```

## 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.4.3 |
| Published | 2020-02-24 |
| First published | 2020-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 39.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Minh Tran |
| Maintainers | dmitriy.sanko, kaputse, adam-dziomdziora-cybercom, zjuice, jluukka, nkovalenko-sc, bo-kh, pdetmer, janek.bug, alexeysergeev, kirillvolkovich, gr4per, ilkkalehtinen, havantkim, eriihine, tamkov-sc, kwierchris, elefantino, samikarj, dsanko, dmitrydivin, alexanderdanilov, egor.stambakio, amourzenkov-sc, jenni, nczeranka, ocmachineuser, lukaszkepa, naniantero |
| Keywords | react-component, react, component, notifications, notification |

## Links

- npm: https://www.npmjs.com/package/@opuscapita/react-notifications
- Repository: https://github.com/OpusCapita/react-notifications
- Issues: https://github.com/OpusCapita/react-notifications/issues
- npm.io page: https://npm.io/package/@opuscapita/react-notifications

## Dependencies (3)

- [classnames](https://npm.io/package/classnames.md) 2.1.1
- [prop-types](https://npm.io/package/prop-types.md) 15.5.10
- [react-transition-group](https://npm.io/package/react-transition-group.md) 1.2.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

- 1.4.3 (latest) — 2020-02-24

## README

# React Notifications

This is a fork with fixed `Object.assign` for compatibility with IE11

[<img src="./screenshot.png" style="width: 100%;" />](http://minhtranite.github.io/react-notifications)

## Installation

```
npm install --save react-notifications
```

## Usage

### Note

**Use only one 'NotificationContainer' component in the app.**

### CSS

#### Webpack:
```js
import 'react-notifications/lib/notifications.css';
```

#### Other
```html
<link rel="stylesheet" type="text/css" href="path/to/notifications.css">
```

### JS

```js
import React from 'react';
import {NotificationContainer, NotificationManager} from 'react-notifications';

class Example extends React.Component {
  createNotification = (type) => {
    return () => {
      switch (type) {
        case 'info':
          NotificationManager.info('Info message');
          break;
        case 'success':
          NotificationManager.success('Success message', 'Title here');
          break;
        case 'warning':
          NotificationManager.warning('Warning message', 'Close after 3000ms', 3000);
          break;
        case 'error':
          NotificationManager.error('Error message', 'Click me!', 5000, () => {
            alert('callback');
          });
          break;
      }
    };
  };

  render() {
    return (
      <div>
        <button className='btn btn-info'
          onClick={this.createNotification('info')}>Info
        </button>
        <hr/>
        <button className='btn btn-success'
          onClick={this.createNotification('success')}>Success
        </button>
        <hr/>
        <button className='btn btn-warning'
          onClick={this.createNotification('warning')}>Warning
        </button>
        <hr/>
        <button className='btn btn-danger'
          onClick={this.createNotification('error')}>Error
        </button>

        <NotificationContainer/>
      </div>
    );
  }
}

export default Example;
```

### UMD

```html
<link rel="stylesheet" type="text/css" href="path/to/react-notifications/dist/react-notifications.css">
<script src="path/to/react-notifications/dist/react-notifications.js"></script>
```

```js
const NotificationContainer = window.ReactNotifications.NotificationContainer;
const NotificationManager = window.ReactNotifications.NotificationManager;
```

Example [here](https://codepen.io/minhtranite/pen/RgoaLL)

## NotificationContainer Props

| Name | Type | Default | Required |
|------|------|---------|----------|
| enterTimeout | number | 400 | false |
| leaveTimeout | number | 400 | false |

## NotificationManager API

- NotificationManager.info(message, title, timeOut, callback, priority);
- NotificationManager.success(message, title, timeOut, callback, priority);
- NotificationManager.warning(message, title, timeOut, callback, priority);
- NotificationManager.error(message, title, timeOut, callback, priority);

| Name | Type | Description |
|------|------|-------------|
| message | string | The message string |
| title | string | The title string |
| timeOut | integer | The popup timeout in milliseconds |
| callback | function | A function that gets fired when the popup is clicked |
| priority | boolean | If true, the message gets inserted at the top |

## Example
View [demo](http://minhtranite.github.io/react-notifications) or example folder.

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