Files
Octopus-React-Wp/frontend/src/components/hooks/useIsTouchDevice.jsx
T
2025-01-03 01:03:52 +01:00

14 lines
355 B
React

import { useEffect, useState } from "react";
export const useIsTouchDevice = () => {
const [isTouchDevice, setIsTouchDevice] = useState(false);
useEffect(() => {
const checkTouchDevice = () => {
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
};
checkTouchDevice();
}, []);
return isTouchDevice;
};