Created
June 22, 2019 04:28
-
-
Save jsmanifest/5f5f08f6241917cb54749f3cd0eb3ab9 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' | |
import App from './App' | |
const Root = () => { | |
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