utils#addOnlineStatusObserver JavaScript Examples
The following examples show how to use
utils#addOnlineStatusObserver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.js From Queen with MIT License | 6 votes |
App = () => {
const { configuration } = useConfiguration();
const [init, setInit] = useState(false);
const [online, setOnline] = useState(navigator.onLine);
useEffect(() => {
if (!init) {
addOnlineStatusObserver(s => {
setOnline(s);
});
setInit(true);
}
}, [init]);
return (
<root.div id="queen-container" style={customStyle}>
{configuration && (
<AppContext.Provider value={{ ...configuration, online: online }}>
<StyleProvider>
<ServiceWorkerNotification standalone={configuration.standalone} />
<AuthProvider authType={configuration.authenticationType}>
<BrowserRouter>
<Rooter />
</BrowserRouter>
</AuthProvider>
</StyleProvider>
</AppContext.Provider>
)}
{!configuration && <Preloader message={D.waitingConfiguration} />}
</root.div>
);
}