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

use-mobile.ts — ui Source File

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

Entity Profile

Dependency Diagram

graph LR
  4bab5572_1e01_8aa9_2b40_eebc106634c2["use-mobile.ts"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  4bab5572_1e01_8aa9_2b40_eebc106634c2 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  style 4bab5572_1e01_8aa9_2b40_eebc106634c2 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.ts do?
use-mobile.ts is a source file in the ui codebase, written in typescript. It belongs to the DocumentationAtlas domain, Changelog subdomain.
What functions are defined in use-mobile.ts?
use-mobile.ts defines 1 function(s): useIsMobile.
What does use-mobile.ts depend on?
use-mobile.ts imports 1 module(s): react.
Where is use-mobile.ts in the architecture?
use-mobile.ts is located at apps/v4/examples/base/hooks/use-mobile.ts (domain: DocumentationAtlas, subdomain: Changelog, directory: apps/v4/examples/base/hooks).

Analyze Your Own Codebase

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

Try Supermodel Free