Created
February 25, 2020 11:20
-
-
Save JustAyush/bc1aa4ba750b3c5c7ddf000f304d3d78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// React | |
import React, {useState, useEffect} from "react"; | |
// Material UI | |
import { | |
Typography, | |
Snackbar | |
} from "@material-ui/core"; | |
import { makeStyles, useTheme } from "@material-ui/core/styles"; | |
import useMediaQuery from "@material-ui/core/useMediaQuery"; | |
// Material UI Lab | |
import MuiAlert from '@material-ui/lab/Alert'; | |
const useStyles = makeStyles(theme => ({ | |
})); | |
const PostSuccess = (props) => { | |
const theme = useTheme(); | |
const mobile = useMediaQuery(theme.breakpoints.down("640")); | |
const classes = useStyles(); | |
// Local state | |
const [open, setOpen] = useState(false); | |
useEffect(() => { | |
setOpen(true); | |
}, [props.open]) | |
const handleClick = () => { | |
setOpen(true); | |
}; | |
const handleClose = (event, reason) => { | |
if (reason === 'clickaway') { | |
return; | |
} | |
setOpen(false); | |
}; | |
return ( | |
<React.Fragment> | |
<Snackbar open={open} autoHideDuration={2000} onClose={handleClose}> | |
<Alert onClose={handleClose} severity="success"> | |
{props.msg} | |
</Alert> | |
</Snackbar> | |
</React.Fragment> | |
); | |
}; | |
function Alert(props) { | |
return <MuiAlert elevation={6} variant="filled" {...props} />; | |
} | |
export default PostSuccess; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment