Created
June 29, 2020 06:18
-
-
Save velotiotech/b5388afd82c1ce1fcaad4edf0ff68fc1 to your computer and use it in GitHub Desktop.
This file contains 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
// state | |
const [offline, setOffline] = React.useState(false); | |
// effects | |
React.useEffect(() => { | |
window.addEventListener("offline", offlineListener); | |
return () => { | |
window.removeEventListener("offline", offlineListener); | |
}; | |
}, []); | |
{/* add to jsx */} | |
{offline ? ( | |
<div className="banner-offline">The app is currently offline</div> | |
) : null} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment