material-ui-toast
Snackbar component using Material-UI with Redux integration
Install
$ npm install material-ui-toast --save
Setup
Add the Reducer to Redux store
The first step is to add the reducer to your rootReducer when creating Redux's store.
const rootReducer =
Add the SnackbarProvider component to the tree
The second step is to add the SnackbarProvider
component somewhere in your app.
const store = ReactDOM
Component { const snackbar = thisprops const options = message: variant action: false {/* do something... */ } close: true variant: variant snackbar } { <div> <Button variant="contained" color="primary" onClick= { this }> Open Success Toast </Button> <Button variant="contained" color="secondary" onClick= { this }> Open Error Toast </Button> <Button variant="contained" color="primary" onClick= { this }> Open Warning Toast </Button> <Button variant="contained" color="secondary" onClick= { this }> Open info Toast </Button> </div> } MyComponent
API
const options = {message:'Archived',action: false,handleAction: () => {},close: true,variant: 'info'
snackbar.show(options)
message
(string) – message to displayaction
(string, optional) – label for the action buttonhandler
(function, optional) – click handler for the action buttonclose
(string, optional) – handle close optionvariant
(string) – handle variant option (info, success, error, warning)