File size: 643 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import React from 'react'
import { Snackbar } from '@material-ui/core';

// Snackbar that allows you to set the content, visibility 
// and change visibility from parent component
export default function SnackBarContent(props) {

  const { content, visible, setVisible } = props;

  // When opened, closes itself after 2.5sec
  const handleSnackBarOpen = () => {
    setTimeout(() => {
      setVisible(false);
    }, 2500)
  }

  return (
    <Snackbar
      open={visible}
      message={content}
      anchorOrigin={{
        vertical: 'bottom',
        horizontal: 'left'
      }}
      onEntered={() => handleSnackBarOpen()}
    />
  )
}