• Stars
    star
    113
  • Rank 308,219 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Redux powered notification React components.

react-redux-notifications

Build Status

Say you have a form with an API call and when the form submit succeeds you want to show the user a success message, or in the event of a failure, show them a failure message.

React-redux-notifications is a redux middleware powered notification system which makes this super easy in a decoupled way.

Setup

// Reducer setup
import { reducer as notifications } from 'react-redux-notifications'

const todoApp = combineReducers({
    notifications,
    ...restOfMiddleware,
})

// Middleware setup
import { middleware as NotificationMiddleware } from 'react-redux-notifications'

let store = createStore(
    myAppReducers,
    compose(
        applyMiddleware(ReduxThunk, NotificationMiddleware),
        window.devToolsExtension ? window.devToolsExtension() : _ => _,
    ),
)

// To use a different key to middleware
import { createMiddleware } from 'react-redux-notifications'
import { reducer as myCustomKey } from 'react-redux-notifications'

const todoApp = combineReducers({
    myCustomKey,
    ...restOfMiddleware,
})

const NotificationMiddleware = createMiddleware('myCustomKey')

let store = createStore(
    myAppReducers,
    compose(
        applyMiddleware(ReduxThunk, NotificationMiddleware),
        window.devToolsExtension ? window.devToolsExtension() : _ => _,
    ),
)

<InlineNotification
  message='Api call successful!'
  triggeredBy={API_CALL_SUCCESS}
  reduxKey="myCustomKey" />

Example usage

<InlineNotification
  message='Api call successful!'
  triggeredBy={API_CALL_SUCCESS}
  showDismiss />

<InlineNotification
  defaultMessage='Api call successful!'
  triggeredBy={DIFFERENT_API_CALL_SUCCESS}
  hideAfter={500} />

API

InlineNotification component

  • triggeredBy - either string or array of strings defining which redux event(s) to listen for
  • defaultMessage - The fallback message to render. notificationMessage on the triggering event type will take precident
  • hideAfter - Hide notification after specified number of ms
  • showDismiss - Show the default dismiss button
  • renderDismiss - Override the rendering of the dismiss button (this has no effect when renderNotification is specified, as dismiss is part of the notification)
  • renderNotification - Override rendering each notification function(notification) { return <div key={notification.key}>{notification.message}</div> }
  • renderContainer - Override the container render function(notifications) { return <div id='notificationContainer'>{notifications}</div> }
    • notifications are the rendered components, you need to specify renderContainer and renderNotification separately
  • reduxKey - If not using the default notifications key for redux, your key can be specified here

notification

The notification object which is passed to renderNotification

{
    key: '<unique key used as react component key>'
    message: '<notificationMessage || defaultMessage>'
    trigger: '<redux event which triggered the notification>'
}

License

react-redux-notifications is available under MIT. See LICENSE for more details.

More Repositories

1

WebApi.Hal

Adds support for the Hal Media Type (and Hypermedia) to Asp.net Web Api
C#
212
star
2

react-popout

React popout is a React component wrapping window.open allowing you to host content in a browser popup window.
JavaScript
188
star
3

VSTOContrib

VSTO Contrib lets you easily unit test, use IoC/DI and develop in a MVVM style within Office Add-ins. It supports Outlook, Word, Excel and PowerPoint 2007 or 2010, and has both .net 3.5 and 4.0 builds
C#
130
star
4

SettingsProvider.net

Simple Settings provider for .net applications
C#
59
star
5

ExpressionToString

Expression.ToString() is not so nice to look at sometimes, this library will ToString your expression in the way you want
C#
26
star
6

GitHubFlowVersion

The easy way to use semantic versioning (semver.org) with GitHub Flow
C#
18
star
7

WebPack-React-Starter

Understanding starter repos is sometimes hard, this repo will show you how we got there. Commit by commit
18
star
8

VSTest.TeamCityLogger

Enables TeamCity to display output when tests are run through VSTest.console.exe
C#
9
star
9

Drone

Drone gives you a birdseye view of all your OSS projects to help you see what to do next. It may even do some of it for you down the track!
JavaScript
9
star
10

TfsBuildResultPublisher

Based off http://blogs.msdn.com/b/jpricket/archive/2010/02/23/creating-fake-builds-in-tfs-build-2010.aspx and http://msmvps.com/blogs/vstsblog/archive/2011/04/26/creating-fake-builds-in-tfs-build-2010-using-the-command-line.aspx
C#
8
star
11

spectacle-typescript-boilerplate

Boilerplate for https://github.com/FormidableLabs/spectacle using TypeScript
TypeScript
8
star
12

XamlAttributeOrderingCodeCleanup

ReSharper Plugin which orders Xaml Attributes
C#
7
star
13

ndc-sydney-pulumi-demo

TypeScript
6
star
14

XText

Allows you to create nicely formatted WPF text from code behind with a syntax similar to the way XDocuments work
C#
6
star
15

SqlConnectionControl

Code for http://jake.ginnivan.net/wpf-sql-connection-user-control
C#
6
star
16

UITextBlock

Wpf TextBlock that supports UI Automation and some other nice things
C#
4
star
17

urban-plate

JavaScript
4
star
18

gru

Gru is a node clustering helper, because he is the leader of the minions
TypeScript
4
star
19

practical-typescript

TypeScript
4
star
20

AsyncAutomapper

C#
3
star
21

TestCaseAutomationAssigner

Allows you to assign non-mstest tests to Test Cases in TFS
C#
3
star
22

AsyncAllTheThings

JavaScript
2
star
23

DelegateInvoker

Invoke methods via reflection without wrapping errors in a TargetInvocationException
C#
2
star
24

jakeginnivan.github.io

My Blog
JavaScript
2
star
25

wee-dram

JavaScript
2
star
26

example-project-structure

Example of how I setup my NPM projects
JavaScript
2
star
27

merge-refs-hook

This package makes it easy to have a component which requires a ref but also wants to support forwarding refs
TypeScript
2
star
28

modern-typescript-is-awesome-demos

1
star
29

advent-of-code

JavaScript
1
star
30

vite-ssr-build-issue

TypeScript
1
star
31

getting-more-out-of-typescript

TypeScript
1
star
32

IsThatEvenJS

JavaScript
1
star
33

dotfiles

Shell
1
star
34

node-git-release-notes

TypeScript
1
star
35

es6-samples

TypeScript
1
star
36

pulumi-fargate-task

TypeScript
1
star
37

pulumi-locked

Pulumi CLI wrapper which supports taking locks in DynamoDB.
JavaScript
1
star
38

ArgyBargy

A simple clean API for showing flexible WPF dialogs
C#
1
star
39

react-json-pages

Create your layouts and components then compose them with JSON. Opens up opportunities to CMS manage your React pages and cut down on boilerplate across pages. Useful if you are building websites with React rather than applications
1
star