replace function with variable

This commit is contained in:
Mark Kaylor 2022-03-29 17:21:06 +02:00
parent fc59c6e2ea
commit ef8091821f

View File

@ -1,12 +1,12 @@
import { useEffect, useState } from 'react';
const getOnLineStatus = () =>
typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean'
? navigator.onLine
: true;
const useNavigatorOnLine = () => {
const [isOnline, setIsOnline] = useState(getOnLineStatus());
const onlineStatus =
typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean'
? navigator.onLine
: true;
const [isOnline, setIsOnline] = useState(onlineStatus);
const setOnline = () => setIsOnline(true);
const setOffline = () => setIsOnline(false);