import React from 'react';
import { Snackbar } from "@material-ui/core";
import { useUserContext }  from './Contexts/UserContext';

export const MessageBar = () => {
  const { error, setError } = useUserContext();
  const open = (error !== null);

  return (<Snackbar
    open={open}
    message={error}
    anchorOrigin={{ vertical: "top", horizontal: "center" }}
    autoHideDuration={10000}
    onClose={() => setError(null)}/>)
}
