Skip to main content

Offline Indicator

This is utils to check whether the user is offline or not. This basically will check the navigator.onLine property and listen to the online and offline events to update the state accordingly.

To use it in your component, simply import the hook useOfflineIndicator and use it to get the current offline status of the user.

import { useOfflineIndicator } from '@traveloka/core';
function MyComponent() {
const isOffline = useOfflineIndicator();

return <div>{isOffline ? 'You are offline' : 'You are online'}</div>;
}