Improve mobile detection logic to handle server-side rendering

Add a check for `window` existence in `useIsMobile` hook to prevent errors during SSR.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: f44f1d1b-1dd8-407b-8603-db12902e1a15
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
pac7
2025-10-04 14:24:37 +00:00
parent ea90eef57a
commit 3389c3d12c

View File

@@ -6,6 +6,8 @@ export function useIsMobile() {
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
React.useEffect(() => {
if (typeof window === 'undefined') return;
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);