material-ui-snackbar-redux
[DEPRECATED] Snackbar component using Material-UI v1 with Redux integration
Deprecation Notice
This package has been deprecated. Please use notistack instead.
Install
$ npm install material-ui-snackbar-redux --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
SnackbarProvider Props
Name | Type | Default | Description |
---|---|---|---|
children | node |
The children that are wrapped by this provider. | |
SnackbarProps | object |
Properties applied to the Snackbar element. |
Usage
Use withSnackbar HOC
You can display snackbar messages with the withSnackbar
HOC and the injected snackbar
prop in your components.
Component { const snackbar = thisprops snackbar } { <div> <Button className=classesbutton onClick=thishandleClick> Open snackbar </Button> </div> } MyComponent
API
snackbar.show(message, [action, handler])
message
(string) – message to displayaction
(string, optional) – label for the action buttonhandler
(function, optional) – click handler for the action button
Dispatch actions
You may use some libraries to handle asynchronous actions or side effects, like redux-thunk, redux-saga and redux-observable. In this context, you can use snackbarActions
action creator to dispath actions that show snackbars.