React & Redux based notifications center.
Thanks to Redux, the notification objects are maintained within Redux Store's State and are fired by Actions,
Features such auto dismiss and styling are supported (see below)
npm install --save re-notif
Note: for the fade animation to work properly, the css file re-notif/lib/re-notif.css must be included
Enhance Your Redux root reducer with the notification reducer:
import { reducer as notifReducer } from 're-notif';
combineReducers({
notifs: notifReducer,
...more reducers here...
})In your application DOM tag put the Notifs component
import { Notifs } from 're-notif';
class App extends Component {
render() {
<div className="content">
<Notifs/>
</div>
}
}Thanks to Redux, sending notification is simply done by firing an Action:
import { reducer as notifReducer, actions as notifActions, Notifs } from 're-notif'; const { notifSend } = notifActions;
class Demo extends Component { send() { this.props.dispatch(notifSend({message: 'hello world', kind: 'info', dismissAfter: 2000})); }
render() { Send } }
Watch the demo or checkout its source code
The CSS classes to attach to an
infokind notification.
The CSS classes to attach to an
successkind notification.
The CSS classes to attach to an
warningkind notification.
The CSS classes to attach to an
dangerkind notification.
A custom component to render for every notification fired, component will have the following props:
The notification's message.
The notifications reducer, should be mounted under
notifs.
Send a notification
The notification message
The notification kind, can be one of:
info,success,warning,danger.
Auto dismiss the notification after the given number of MS.
Clear all current notifications.