summaryrefslogtreecommitdiff
path: root/src/core/components/views/MobileView.jsx
blob: fc8fb6a881ee2b478e4eeffbb454bca17f76e13c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import useDevice from '@/core/hooks/useDevice'
import { useEffect, useState } from 'react'

const initialView = <></>

const MobileView = ({ children }) => {
  const { isMobile } = useDevice()
  const [view, setView] = useState(initialView)

  useEffect(() => {
    if (isMobile) {
      setView(children)
    } else {
      setView(initialView)
    }
  }, [isMobile, children])

  return view
}

export default MobileView