mirror of
https://github.com/colanode/colanode.git
synced 2025-12-16 19:57:46 +01:00
18 lines
390 B
TypeScript
18 lines
390 B
TypeScript
import { useMemo } from 'react';
|
|
|
|
import { useApp } from '@colanode/ui/contexts/app';
|
|
|
|
const mobileDeviceRegex =
|
|
/Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i;
|
|
|
|
export const useIsMobile = (): boolean => {
|
|
const app = useApp();
|
|
if (app.type === 'mobile') {
|
|
return true;
|
|
}
|
|
|
|
return useMemo(() => {
|
|
return mobileDeviceRegex.test(navigator.userAgent);
|
|
}, []);
|
|
};
|