From 471d8f47146c3460d3ed125905374a79e8ddd436 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 23 Feb 2020 05:49:52 +0300 Subject: [PATCH] useScreenType replaced with useMobile; hide breadcrumbs on mobile --- src/components/App/index.tsx | 6 ++++-- src/components/Navigation/index.tsx | 6 +++--- src/hooks/useMobile.ts | 5 +++++ src/hooks/useScreenType.ts | 15 --------------- 4 files changed, 12 insertions(+), 20 deletions(-) create mode 100644 src/hooks/useMobile.ts delete mode 100644 src/hooks/useScreenType.ts diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 2ca49e69..cb13d895 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -10,6 +10,7 @@ import { Breadcrumbs } from '../Breadcrumbs' import { IBreadcumbsPart } from 'src/types' import { useRouter } from 'next/router' import { route } from 'next/dist/next-server/server/router' +import { useMobile } from 'src/hooks/useMobile' const Navigation = dynamic(() => import('../Navigation').then(mod => mod.Navigation), { ssr: false, @@ -23,6 +24,7 @@ export interface IAppProps { } export const App: React.FC = props => { + const hideBreadcrumbs = useMobile() const router = useRouter() const wide = props.wide ?? false const blockStyle = { @@ -35,8 +37,8 @@ export const App: React.FC = props => { header={(
- {!props.breadcrumbs ? null : ( - + {hideBreadcrumbs || !props.breadcrumbs ? null : ( + = props => { - const isMobile = useScreenType(['phone', 'tablet']) + const collapseMenu = useMobile() const [open, setOpen] = useState(false) const onClick = useCallback( () => { @@ -34,7 +34,7 @@ export const Navigation: React.FC = props => { } `} - {isMobile ? ( + {collapseMenu ? ( { - setMatch(isPhone && types.includes('phone')) - }, [isPhone]) - - return match -}