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

16 lines
472 B
JavaScript

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;