1 import { useEffect, useState } from 'react';
3 export const useNavigatorOnline = () => {
4 const [online, setOnline] = useState(navigator.onLine);
7 const handler = () => setOnline(navigator.onLine);
8 window.addEventListener('online', handler);
9 window.addEventListener('offline', handler);
12 window.removeEventListener('online', handler);
13 window.removeEventListener('offline', handler);