ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
19 lines • 748 B
JavaScript
import * as React from 'react';
import { onlineManager } from '@tanstack/react-query';
/**
* Hook to determine if the application is offline.
* It uses the onlineManager from react-query to check the online status.
* It returns true if the application is offline, false otherwise.
* @returns {boolean} - True if offline, false if online.
*/
export var useIsOffline = function () {
var _a = React.useState(onlineManager.isOnline()), isOnline = _a[0], setIsOnline = _a[1];
React.useEffect(function () {
var handleChange = function () {
setIsOnline(onlineManager.isOnline());
};
return onlineManager.subscribe(handleChange);
}, []);
return !isOnline;
};
//# sourceMappingURL=useIsOffline.js.map