// ** MUI Imports import Box from '@mui/material/Box' import Button from '@mui/material/Button' import Typography from '@mui/material/Typography' // ** Icon Imports import Icon from 'src/@core/components/icon' // ** Third Party Components import toast from 'react-hot-toast' const ToastPromise = () => { const handleClick = () => { const myPromise = new Promise((resolve, reject) => { setTimeout(() => { if (Math.random() < 0.5) { resolve('foo') } else { reject('fox') } }, 1000) }) return toast.promise(myPromise, { loading: 'Loading', success: 'Got the data', error: 'Error when fetching' }) } return ( Promise Update automatically when promise resolves / fails. ) } export default ToastPromise