All Projects → nicmesan → react-redux-notification

nicmesan / react-redux-notification

Licence: MIT license
The simplest way to implement a notification system in your React-Redux app

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to react-redux-notification

Psslack
PowerShell module for simple Slack integration
Stars: ✭ 231 (+725%)
Mutual labels:  notifications
mobile-messaging-sdk-ios
Mobile Messaging SDK for iOS
Stars: ✭ 45 (+60.71%)
Mutual labels:  notifications
ChatApp
Chat app based on Firebase tools.
Stars: ✭ 88 (+214.29%)
Mutual labels:  notifications
Herbe
Daemon-less notifications without D-Bus. Minimal and lightweight.
Stars: ✭ 235 (+739.29%)
Mutual labels:  notifications
Netdata
Real-time performance monitoring, done right! https://www.netdata.cloud
Stars: ✭ 57,056 (+203671.43%)
Mutual labels:  notifications
mongodb-backup-manager
🌿 A Full-stack MongoDB Backup System.
Stars: ✭ 42 (+50%)
Mutual labels:  notifications
Alert After
Get a desktop notification after a command finishes executing.
Stars: ✭ 230 (+721.43%)
Mutual labels:  notifications
laravel-pipes
Aims making it easier to organize internal handling of incoming webhooks.
Stars: ✭ 21 (-25%)
Mutual labels:  notifications
notifier
📟 Extensible library for building notifications and sending them via different delivery channels
Stars: ✭ 24 (-14.29%)
Mutual labels:  notifications
sns-laravel
A library to enable sending and receiving broadcasts to and from SNS topics in Laravel and Lumen.
Stars: ✭ 23 (-17.86%)
Mutual labels:  notifications
Toasted Notes
simple, flexible toast notifications for react
Stars: ✭ 241 (+760.71%)
Mutual labels:  notifications
React Materialui Notifications
Spec compliant notifications for react and material ui users
Stars: ✭ 252 (+800%)
Mutual labels:  notifications
vue-dk-toast
Lightweight toast-notification plugin for Vue 3 🍞
Stars: ✭ 23 (-17.86%)
Mutual labels:  notifications
Overlay support
a flutter toast and notification library
Stars: ✭ 232 (+728.57%)
Mutual labels:  notifications
robusta
Open source Kubernetes monitoring, troubleshooting, and automation platform
Stars: ✭ 772 (+2657.14%)
Mutual labels:  notifications
React Hot Toast
Smoking hot React Notifications 🔥
Stars: ✭ 4,282 (+15192.86%)
Mutual labels:  notifications
sutanlab.id
☕️ My Personal Homepage & Blog site with NextJS. 🇺🇸 🇮🇩
Stars: ✭ 39 (+39.29%)
Mutual labels:  notifications
SnitchDNS
Database Driven DNS Server with a Web UI
Stars: ✭ 169 (+503.57%)
Mutual labels:  notifications
mac-ibm-notifications
macOS agent used to display custom notifications and alerts to the end user.
Stars: ✭ 206 (+635.71%)
Mutual labels:  notifications
laravel-fcm-notification-channel
No description or website provided.
Stars: ✭ 23 (-17.86%)
Mutual labels:  notifications

react-redux-notification

The simplest way to implement a notification system in your React-Redux app

Installation

npm install --save react-redux-notification

Getting started

CSS

Webpack:

import 'react-redux-notification/src/styles/notifications.css';

Other

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

Middleware

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import App from './my_app';
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import {notificationsMiddleware} from 'react-redux-notification'
import rootReducer from './my_reducer';

const store = createStore(
    rootReducer,
	applyMiddleware(notificationsMiddleware),

	);

ReactDOM.render(
	<Provider store={store}>
		<App />
	</Provider>
	, document.querySelector('.container'));

Reducer

import { combineReducers } from 'redux';
import { notificationsReducer } from '../src'

const rootReducer = combineReducers({
    notificationsReducer,
});

export default rootReducer;

Using the library

Notifications container

First, add the notifications container in your main component:

import React, { Component } from 'react';
import { Notifications } from 'react-redux-notification'

class MainComponent extends Component {
  render () {
    return (
      <div>
        //.....
        <Notifications duration={1000}/>
      </div>
    )
}
//...

Notification container Props

Name Type Default Required
duration number 3000 false
  • duration: Time in ms each single notification will be rendered before disappearing

Actions

Adding a single notification

You can add a notification calling the addNotification action:

import React, { Component } from 'react';
import { Notifications } from 'react-redux-notification';
import { addNotification } from 'react-redux-notification/actions';

class MainComponent extends Component {
  
  addNotification () {
    const notificationPayload = {
            text: 'A notification Message',
        };
        
    this.props.addNotification(notificationPayload)
 }
 
  render () {
    return (
      <div>
        <button onClick={this.addNotification.bind(this)}
        //.....
        <Notifications duration={1000}/>
      </div>
    )
}
//...

Or just add the notifiaction key to any other action you are dispatching, and the library middleware will take care of the rest:

// Some random action in your app

exports function doSomeStuff () {
  type: 'doSomeStuff',
  notification: {
    text: 'Stuff done'
}

Single notification Props

Name Type Default Required
message string None true
className string Default styles false
unique boolean false false
type string None false
  • message: Text message to be rendered.
  • className: Class name to be applied to this specific notification. The library comes with an error class to render error like notifications.
  • unique: If true, it will check if a notification of the same "type" exists and if it does, will replace it instead of stacking it.
  • type: Related to the unique props, group related notifications of the same type if you don't want them to stack.

Clearing all notifications

Call clearAllNotifications action to clear all current notifications:

import React, { Component } from 'react';
import { Notifications } from 'react-redux-notification';
import { clearAllNotifications } from 'react-redux-notification/actions';

class MainComponent extends Component {
  
  clearAllNotifications () {
    this.props.clearAllNotifications()
 }
 
  render () {
    return (
      <div>
        <button onClick={this.clearAllNotifications.bind(this)}
        //.....
        <Notifications duration={1000}/>
      </div>
    )
}
//...

Demo

Check the demo folder for an example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].