unis_crm/frontend1/node_modules/@rc-component/util/es/hooks/useMobile.js

16 lines
472 B
JavaScript
Raw Normal View History

2026-03-26 09:29:55 +00:00
import { useState } from 'react';
import isMobile from "../isMobile";
import useLayoutEffect from "./useLayoutEffect";
/**
* Hook to detect if the user is on a mobile device
* Notice that this hook will only detect the device type in effect, so it will always be false in server side
*/
const useMobile = () => {
const [mobile, setMobile] = useState(false);
useLayoutEffect(() => {
setMobile(isMobile());
}, []);
return mobile;
};
export default useMobile;