think/packages/client/src/hooks/use-on-mobile.tsx

13 lines
372 B
TypeScript
Raw Normal View History

2022-05-22 14:09:26 +00:00
import { createGlobalHook } from './create-global-hook';
import { useToggle } from './use-toggle';
const useOnMobile = (defaultIsMobile) => {
const [isMobile, toggleIsMobile] = useToggle(defaultIsMobile);
return {
isMobile,
toggleIsMobile,
};
};
export const IsOnMobile = createGlobalHook<{ isMobile?: boolean; toggle: () => void }, boolean>(useOnMobile);