One Calendar is a privacy-first calendar web app built with Next.js. It has modern security features, including e2ee, password-protected sharing, and self-destructing share links ๐Ÿ“… calendar.xyehr.cn
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: update hook

authored by

Evan Huang and committed by
GitHub
bdaac693 aab030c7

+21 -19
-19
hooks/use-mobile.tsx
··· 1 - import * as React from "react" 2 - 3 - const MOBILE_BREAKPOINT = 768 4 - 5 - export function useIsMobile() { 6 - const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined) 7 - 8 - React.useEffect(() => { 9 - const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`) 10 - const onChange = () => { 11 - setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) 12 - } 13 - mql.addEventListener("change", onChange) 14 - setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) 15 - return () => mql.removeEventListener("change", onChange) 16 - }, []) 17 - 18 - return !!isMobile 19 - }
+21
hooks/useMobile.tsx
··· 1 + import * as React from "react"; 2 + 3 + const MOBILE_BREAKPOINT = 768; 4 + 5 + export function useIsMobile() { 6 + const [isMobile, setIsMobile] = React.useState(false); 7 + 8 + React.useEffect(() => { 9 + if (typeof window !== "undefined") { 10 + const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`); 11 + const onChange = () => { 12 + setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); 13 + }; 14 + mql.addEventListener("change", onChange); 15 + setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); 16 + return () => mql.removeEventListener("change", onChange); 17 + } 18 + }, []); 19 + 20 + return isMobile; 21 + }