JSPM

react-redux-snackbar

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2746
  • Score
    100M100P100Q117256F
  • License MIT

A snackbar (displays toasts) for reactjs, using the redux state container

Package Exports

  • react-redux-snackbar

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-redux-snackbar) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-redux-snackbar Gemnasium gzipped size

A snackbar (displays toasts) for reactjs, using the redux state container. Follows the material design guidelines. Its flexible and customizable at less than 2.5kB gzipped, and has no dependencies (other than that you must use React and Redux in your app of course).

Install

Install using yarn:

yarn add react-redux-snackbar

Or npm:

npm install --save react-redux-snackbar

Implementation

  1. Add the reducer
// Somewhere where you create your redux-store:
import { createStore, combineReducers } from 'redux';
import { snackbarReducer } from 'react-redux-snackbar'; // Import it
const reducers = {
  // ... reducers ...
  snackbar: snackbarReducer // Make sure its mounted using the "snackbar" key
  // ... reducers ...
};
const reducer = combineReducers(reducers);
const store = createStore(reducer);
  1. Add the React-component somewhere in your app
import { Provider }  from 'react-redux';
import { Snackbar } from 'react-redux-snackbar';

<Provider store={store}>
    // This is maybe in your App.js or something
    // Just put the component somewhere in your app
    <Snackbar />
</Provider>
  1. Then use it by dispatching the redux-actions, anywhere in your app
import { showSnack, dismissSnack } from 'react-redux-snackbar';

dispatch(showSnack('myUniqueId', {
    label: 'Yay, that actually worked!',
    timeout: 7000,
    button: { label: 'OK, GOT IT' }
}));

// Should you want to remove it programatically:

dispatch(dismissSnack('myUniqueId'));

More docs coming soon

Changelog