-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug]: Can't find use-mobile hook in shadcn doc #6133
Comments
the import generated in the sidebar.tsx (/components/sidebar.tsx) is
this hook is not installed via installation command. Any ideas where I get this? |
@akshay-nm You can get this hook via the repo: This is the hook: 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
} |
i tried It worked, but one issue is, the shadcn add command overwrites the lib/utils.tsx (not related to this issue). |
PR created to close issue. |
@ardevik pls close issue once PR will be accepted. @akshay-nm consider to create new issue for such task. It will be CLI development. |
@akshay-nm Also it looks strange that utils.tsx file has been overwritten. Because default behavior for add command is: And there is also check in file So, please make sure to test it again and if it happend create new issue. |
Describe the bug
Because restricted firewall in my company, I can't use the cli for adding components because it point to external registry, so I'm using manual installation for sidebar component and adding requirement one by one. Until I want add the @/components/hooks/use-mobile but can't find the example
Affected component/components
Sidebar
How to reproduce
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Before submitting
The text was updated successfully, but these errors were encountered: