This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
scoresaber-reloadedv3/src/hooks/use-is-mobile.ts

18 lines
409 B
TypeScript
Raw Normal View History

2024-09-30 06:20:58 +00:00
import { useEffect, useState } from "react";
2024-09-28 14:19:51 +00:00
export function useIsMobile() {
const [isMobile, setIsMobile] = useState(false);
useEffect(() => {
const handleResize = () => {
setIsMobile(window.innerWidth < 768);
};
window.addEventListener("resize", handleResize);
handleResize();
return () => window.removeEventListener("resize", handleResize);
}, []);
return isMobile;
}