snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
14
apps/v4/public/r/styles/new-york/use-mobile.json
Normal file
14
apps/v4/public/r/styles/new-york/use-mobile.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
||||
"name": "use-mobile",
|
||||
"type": "registry:hook",
|
||||
"author": "shadcn (https://ui.shadcn.com)",
|
||||
"files": [
|
||||
{
|
||||
"path": "hooks/use-mobile.tsx",
|
||||
"content": "import * as React from \"react\"\n\nconst MOBILE_BREAKPOINT = 768\n\nexport function useIsMobile() {\n const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)\n\n React.useEffect(() => {\n const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)\n const onChange = () => {\n setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)\n }\n mql.addEventListener(\"change\", onChange)\n setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)\n return () => mql.removeEventListener(\"change\", onChange)\n }, [])\n\n return !!isMobile\n}\n",
|
||||
"type": "registry:hook",
|
||||
"target": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user