material-ui-redux-snackbar
v1.0.0
Published
A snackbar for reactjs, using the redux state container and material-ui
Downloads
6
Maintainers
Readme
material-ui-redux-snackbar
A snackbar for reactjs using Redux that is dependent on the Snackbar from material-ui.
Dependencies
redux
material-ui
Install
Using npm:
npm install --save react-redux-snackbar
Implementation
- Add the reducer
// Somewhere where you create your redux-store:
import { createStore, combineReducers } from 'redux';
import { reduxSnackbarReducer } from 'material-ui-redux-snackbar'; // Import it
const reducers = {
// ... reducers ...
reduxSnackbar: reduxSnackbarReducer
};
const reducer = combineReducers(reducers);
const store = createStore(reducer);
- Add the React-component somewhere in your app (e.g. App.js)
import { Provider } from 'react-redux';
import { Snackbar } from 'react-redux-snackbar';
<Provider store={store}>
<ReduxSnackbar />
</Provider>
- Then use it by dispatching the redux-actions, anywhere in your app
import { displaySnackbarMessage } from 'react-redux-snackbar';
dispatch(displaySnackbarMessage('myUniqueId'));