//create a custom hook to check if the user is online or offline
//created by: Omar Labib
import { useState } from 'react';
import useEventListener from './useEventListener';

export default function useOnlineStatus() {
  const [online, setOnline] = useState(navigator.onLine);

  useEventListener('online', () => setOnline(navigator.onLine));
  useEventListener('offline', () => setOnline(navigator.onLine));

  return online;
}
