Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 29, 2020 06:18
Embed
What would you like to do?
// 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