openclaw/apps/web/app/hooks/use-mobile.ts
kumarabhirup dee323b7ad
fix lint/build errors and bump to 2026.2.15-1.4
- Fix all oxlint errors (curly, no-unused-vars, no-base-to-string,
  no-floating-promises, approx-constant, restrict-template-expressions)
- Fix TS build errors: rewrite update-cli.ts as thin wrapper over
  submodules, restore missing chat abort helpers in chat.ts
- Fix web build: wrap handleNewSession in async for ChatPanelHandle,
  add missing safeString helper to entry-detail-modal
- Bump version to 2026.2.15-1.4 and publish

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-16 00:30:13 -08:00

22 lines
618 B
TypeScript

"use client";
import { useState, useEffect } from "react";
/**
* Returns true when the viewport is narrower than `breakpoint` (default 768px).
* Uses `matchMedia` for efficiency; falls back to `false` during SSR.
*/
export function useIsMobile(breakpoint = 768): boolean {
const [isMobile, setIsMobile] = useState(false);
useEffect(() => {
const mql = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
const update = () => setIsMobile(mql.matches);
update();
mql.addEventListener("change", update);
return () => mql.removeEventListener("change", update);
}, [breakpoint]);
return isMobile;
}