All files / src/components ErrorSnackbar.jsx

25% Statements 2/8
0% Branches 0/1
25% Functions 1/4
14.29% Lines 1/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40          6x                                                                    
import React, { Component } from 'react'
import Snackbar from 'material-ui/Snackbar';
import Button from 'material-ui/Button';
import { withStyles } from 'material-ui/styles';
 
const styles = theme => ({
  snackbar: {
    margin: theme.spacing.unit,
  },
});
 
export class ErrorSnackbar extends Component {
  constructor(props) {
    super(props)
    this.state= {open : true};
  }
  handleRequestClose = () => {
    this.setState({ open: false });
  };
  render() {
    const { classes, message = "" } = this.props;
    const {open} = this.state 
    return (
      <Snackbar
        className={classes.snackbar}
          anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
          open={open}
          SnackbarContentProps={{
            'aria-describedby': 'message-id',
          }}
          action={<Button color="accent" dense onClick={this.handleRequestClose}>
              close
              </Button>}
          message={<span id="message-id">{message}</span>}
        />
    )
  }
}
 
export default withStyles(styles)(ErrorSnackbar)