SPB Git forge

spb/countryatlas

Public
20commits 1branches 0releases
268.3 MBsize
maindefault branch
12 days agolast push
TypeScript 57% Python 38.6% JavaScript 3.6% CSS 0.6%
522 B · 16 lines typescript
Raw Blame History
1'use client';2import { useEffect, useState } from 'react';34/** True at ≥ 768 px (Tailwind `md`). False during SSR and the first client render (mobile-first). */5export function useIsDesktop(): boolean {6  const [desktop, setDesktop] = useState(false);7  useEffect(() => {8    const mq = window.matchMedia('(min-width: 768px)');9    const apply = () => setDesktop(mq.matches);10    apply();11    mq.addEventListener('change', apply);12    return () => mq.removeEventListener('change', apply);13  }, []);14  return desktop;15}16