summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks/use-mobile.tsx
diff options
context:
space:
mode:
authorKha Nguyen <hi@khanguyen.com>2025-07-24 16:50:14 -0500
committerKha Nguyen <hi@khanguyen.com>2025-07-24 16:50:14 -0500
commit262a7d53d63cc9997f730c7f64b7f8ec29723926 (patch)
tree894d6e3986b3ca339dc3ff7ec62fb31b3690be82 /apps/web/src/hooks/use-mobile.tsx
parent5a7745f806edf4a386b8cfd079861f96c3b92baf (diff)
parent5931ddb77aac23ffe1b82d9d7c03afde3e671109 (diff)
downloadopencut-262a7d53d63cc9997f730c7f64b7f8ec29723926.tar.gz
Merge branch 'main' into fix/improve-shortcuts
Diffstat (limited to 'apps/web/src/hooks/use-mobile.tsx')
-rw-r--r--apps/web/src/hooks/use-mobile.tsx24
1 files changed, 13 insertions, 11 deletions
diff --git a/apps/web/src/hooks/use-mobile.tsx b/apps/web/src/hooks/use-mobile.tsx
index 2b0fe1df..48fab93c 100644
--- a/apps/web/src/hooks/use-mobile.tsx
+++ b/apps/web/src/hooks/use-mobile.tsx
@@ -1,19 +1,21 @@
-import * as React from "react"
+import * as React from "react";
-const MOBILE_BREAKPOINT = 768
+const MOBILE_BREAKPOINT = 768;
export function useIsMobile() {
- const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
+ undefined
+ );
React.useEffect(() => {
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
- }
- mql.addEventListener("change", onChange)
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
- return () => mql.removeEventListener("change", onChange)
- }, [])
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
+ };
+ mql.addEventListener("change", onChange);
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
+ return () => mql.removeEventListener("change", onChange);
+ }, []);
- return !!isMobile
+ return !!isMobile;
}