Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 63x 231x 231x 224x 224x 224x 224x 231x 224x 231x | import { useCallback, useEffect, useRef } from "react";
export const useGetOperatingSystem = () => {
const operatingSystemTracker = useRef<
"Windows Phone" | "Android" | "iOS" | undefined
>();
const getOperatingSystem = useCallback(() => {
const userAgent = navigator.userAgent || navigator.vendor;
Iif (/windows phone/i.test(userAgent)) {
return "Windows Phone";
}
Iif (/android/i.test(userAgent)) {
return "Android";
}
Iif (/iPad|iPhone|iPod/.test(userAgent)) {
return "iOS";
}
}, []);
useEffect(() => {
operatingSystemTracker.current = getOperatingSystem();
}, []);
return { getOperatingSystem, operatingSystemTracker };
};
|