Created
February 2, 2020 18:39
-
-
Save jsmanifest/73442aed8187f7c534ab083e8d3215a6 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
import { toast } from 'react-toastify' | |
import { | |
info as toastInfo, | |
success as toastSuccess, | |
toastIds, | |
} from 'util/toast' | |
const onOnline = () => { | |
if (toast.isActive(toastIds.internetOffline)) { | |
toast.dismiss(toastIds.internetOffline) | |
} | |
if (toast.isActive(toastIds.retryInternet)) { | |
toast.dismiss(toastIds.retryInternet) | |
} | |
if (!toast.isActive(toastIds.internetOnline)) { | |
toastSuccess('You are now reconnected to the internet.', { | |
position: 'bottom-center', | |
toastId: toastIds.internetOnline, | |
}) | |
} | |
} | |
const onOffline = () => { | |
if (!toast.isActive(toastIds.internetOffline)) { | |
toastInfo('You are disconnected from the internet right now.', { | |
position: 'bottom-center', | |
autoClose: false, | |
toastId: toastIds.internetOffline, | |
}) | |
} | |
} | |
useInternet({ onOnline, onOffline }) | |
return <App /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment