# redux-notifications

> Redux & React based Notifications center

Latest version **4.0.1** (published 2017-06-27) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install redux-notifications
pnpm add redux-notifications
yarn add redux-notifications
bun add redux-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 | 4.0.1 |
| Published | 2017-06-27 |
| First published | 2016-06-29 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 148 |
| Author | Indexia Technologies, ltd. |
| Maintainers | kylecesmat |

## Links

- npm: https://www.npmjs.com/package/redux-notifications
- Repository: https://github.com/indexiatech/re-notif
- Homepage: http://indexiatech.github.io/re-notif
- Issues: https://github.com/indexiatech/re-notif/issues
- npm.io page: https://npm.io/package/redux-notifications

## Dependencies (4)

- [prop-types](https://npm.io/package/prop-types.md) ^15.5.10
- [react-redux](https://npm.io/package/react-redux.md) ^4.0.0
- [object-assign](https://npm.io/package/object-assign.md) ^4.1.1
- [react-transition-group](https://npm.io/package/react-transition-group.md) ^1.1.3

## Recent versions

- 4.0.1 (latest) — 2017-06-27
- 3.2.1 — 2017-06-27
- 4.0.0 — 2017-06-27
- 3.2.0 — 2017-06-27
- 3.1.0 — 2016-12-15
- 3.0.1 — 2016-10-23
- 3.0.0 — 2016-10-15
- 2.1.1 — 2016-07-27
- 2.1.0 — 2016-07-06
- 2.0.0 — 2016-06-29

## README

# `redux-notifications`

> :warning: The previous package `re-notif` has been deprecated on NPM and renamed to `redux-notifications`. A list of changes can be found in the Changelog. Please update your applications accordingly.

[React](https://github.com/facebook/react) & [Redux](https://github.com/rackt/redux) based notifications center.

Thanks to Redux, the notification objects are maintained within Redux Store's State and are fired by Actions.

## Implementation

##### 1. Installation

`npm install --save redux-notifications`

##### 2. The next thing you need to do is to add the `redux-notifications` `reducer` to Redux.
```js
import { createStore, combineReducers } from 'redux'
import { reducer as notifReducer } from 'redux-notifications';
combineReducers({
  notifs: notifReducer,
  // ... more reducers here ...
})
```

##### 3. Add the `Notifs` component at the root of your app
```js
import { Provider }  from 'react-redux'
import { Notifs } from 'redux-notifications';

<Provider store={store}>
  <div>
    // ... other things like router ...
    <Notifs />
  </div>
</Provider>
```

##### 4. Optionally import default CSS
`redux-notifications` uses [react-css-transition-group](https://facebook.github.io/react/docs/animation.html#high-level-api-reactcsstransitiongroup) with the following classes:
- .notif-transition-enter
- .notif-transition-enter-active
- .notif-transition-leave
- .notif-transition-leave-active

To import the default stylesheet:
```js
import 'redux-notifications/lib/styles.css';
```

## Sending notifications

Thanks to Redux, sending notification is simply done by firing an `Action`:

``` javascript
import { reducer as notifReducer, actions as notifActions, Notifs } from 'redux-notifications';
const { notifSend } = notifActions;

class Demo extends React.Component {
  send() {
    this.props.dispatch(notifSend({
      message: 'hello world',
      kind: 'info',
      dismissAfter: 2000
    }));
  }

  render() {
    <button onClick={this.send}>Send Notification</button>
  }
}
```

## Actions

#### `actions.notifSend({config})`

##### `config.message : node` [required]
> The notification message, can be one of: `string`, `integer`, `element` or `array` containing these types.

##### `config.kind : string` [optional] [default:'info']
> The notification kind, can be one of: `info`, `success`, `warning`, `danger`.

##### `config.id : string` [optional] [default:Date.now()]
> Set an ID for the notification. If not set, defaults to Date.now().

##### `config.dismissAfter : integer` [optional] [default:null]
> Auto dismiss the notification after the given number of milliseconds.

#### `actions.notifClear()`
> Clear all current notifications.

#### `actions.notifDismiss(id)`
> Dismiss a notification by ID

---

## Notifs Component

#### `<Notifs CustomComponent={ReactComponent}/>`

##### `CustomComponent : React component`
> A custom react component can be used instead of the default Notif component

##### `className : string` [optional] [default:null]
> Pass a custom classname to the <Notifs /> component.

##### `componentClassName : string` [optional] [default:'notif']
> The base className for each Notif component. Can be used to override CSS styles.

##### `transitionEnterTimeout : integer` [optional] [default:600]
> Define the react-transition-group enter timeout is milliseconds.

##### `transitionLeaveTimeout : integer` [optional] [default:600]
> Define the react-transition-group leave timeout is milliseconds.

##### `actionLabel : string`
> Label for action click

##### `onActionClick : func`
> Function when action is clicked. Requires `actionLabel` prop

## Development

```
git clone https://github.com/indexiatech/re-notif.git
cd re-notif
npm install
npm run start
```
Listening on localhost:9000

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