Snackbar
/**
* Ecommerce Dashboard
*/
import React, { Component } from 'react'
...
export default class EcommerceDashboard extends Component {
// Snackbar State
state = {
open: false,
};
// Snackbar Functions
handleClick = () => {
this.setState({ open: true });
};
handleClose = (event, reason) => {
if (reason === 'clickaway') {
return;
}
this.setState({ open: false });
};
render() {
...
// Snackbar Code
<div>
<Button variant="contained" color="primary" className="text-white mr-10 mb-10 d-inline-block" onClick={this.handleClick}>simple snackbar</Button>
<Snackbar anchorOrigin={{ vertical: 'bottom', horizontal: 'left', }}
open={this.state.open}
autoHideDuration={6000}
onClose={this.handleClose}
message={<span id="message-id">Note archived</span>}
action={[
<Button variant="contained" key="undo" className="btn-danger btn-sm text-white" dense="true" onClick={this.handleClose}> UNDO </Button>,
<IconButton key="close" aria-label="Close" color="inherit" onClick={this.handleClose} >
<i className="zmdi zmdi-close"></i>
</IconButton>,
]}
/>
</div>


Last updated