14 lines
355 B
React
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;
|
|
}; |