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-28 15:19:51 +01:00
import { useState, useEffect } from "react";
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;
}