mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 22:23:10 +00:00
replace function with variable
This commit is contained in:
parent
fc59c6e2ea
commit
ef8091821f
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user