Home / File/ use-mobile.tsx — ui Source File

use-mobile.tsx — ui Source File

Architecture documentation for use-mobile.tsx, a tsx file in the ui codebase. 1 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  79f20154_a5aa_2c9e_29da_1908d1849703["use-mobile.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  79f20154_a5aa_2c9e_29da_1908d1849703 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  style 79f20154_a5aa_2c9e_29da_1908d1849703 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as React from "react"

const MOBILE_BREAKPOINT = 768

export function useIsMobile() {
  const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)

  React.useEffect(() => {
    const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
    const onChange = () => {
      setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
    }
    mql.addEventListener("change", onChange)
    setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
    return () => mql.removeEventListener("change", onChange)
  }, [])

  return !!isMobile
}

Subdomains

Functions

Dependencies

  • react

Frequently Asked Questions

What does use-mobile.tsx do?
use-mobile.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in use-mobile.tsx?
use-mobile.tsx defines 1 function(s): useIsMobile.
What does use-mobile.tsx depend on?
use-mobile.tsx imports 1 module(s): react.
Where is use-mobile.tsx in the architecture?
use-mobile.tsx is located at deprecated/www/registry/default/hooks/use-mobile.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/default/hooks).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free