MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / useIsDesktop

Function useIsDesktop

ui/src/components/PageSidebarLayout.tsx:36–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36function useIsDesktop(): boolean {
37 const query = '(min-width: 768px)'
38 const [matches, setMatches] = useState(() =>
39 typeof window !== 'undefined' ? window.matchMedia(query).matches : true,
40 )
41
42 useEffect(() => {
43 const mq = window.matchMedia(query)
44 const handler = () => setMatches(mq.matches)
45 setMatches(mq.matches)
46 mq.addEventListener('change', handler)
47 return () => mq.removeEventListener('change', handler)
48 }, [])
49
50 return matches
51}
52
53interface PageSidebarLayoutProps {
54 storageKey: string

Callers 1

PageSidebarLayoutFunction · 0.70

Calls 1

addEventListenerMethod · 0.65

Tested by

no test coverage detected